| 21165 |
ashik.ali |
1 |
package com.spice.profitmandi.web.config;
|
|
|
2 |
|
|
|
3 |
import org.springframework.context.annotation.PropertySource;
|
|
|
4 |
|
|
|
5 |
/*@Configuration*/
|
|
|
6 |
@PropertySource(value = { "classpath:email.properties" })
|
|
|
7 |
public class EmailConfig {
|
|
|
8 |
|
|
|
9 |
/*private static final String SMTP_HOST="smtp.host";
|
|
|
10 |
private static final String SMTP_PORT="smtp.port";
|
|
|
11 |
private static final String EMAIL_USERNAME="email.username";
|
|
|
12 |
private static final String EMAIL_PASSWORD="email.password";
|
|
|
13 |
private static final String MAIL_TRANSPORT_PROTOCOL="mail.transport.protocol";
|
|
|
14 |
private static final String MAIL_SMTP_AUTH="mail.smtp.auth";
|
|
|
15 |
private static final String MAIL_SMTP_STARTTLS_ENABLE= "mail.smtp.starttls.enable";
|
|
|
16 |
private static final String MAIL_DEBUG="mail.debug";
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
@Autowired
|
|
|
20 |
private Environment environment;
|
|
|
21 |
|
|
|
22 |
@Bean(name="mailSender")
|
|
|
23 |
public MailSender getMailSender(){
|
|
|
24 |
final JavaMailSenderImpl javaMailSenderImpl=new JavaMailSenderImpl();
|
|
|
25 |
javaMailSenderImpl.setHost(environment.getRequiredProperty(SMTP_HOST));
|
|
|
26 |
javaMailSenderImpl.setPort(Integer.parseInt(environment.getRequiredProperty(SMTP_PORT)));
|
|
|
27 |
javaMailSenderImpl.setUsername(environment.getRequiredProperty(EMAIL_USERNAME));
|
|
|
28 |
javaMailSenderImpl.setPassword(environment.getRequiredProperty(EMAIL_PASSWORD));
|
|
|
29 |
javaMailSenderImpl.setJavaMailProperties(getJavaMailProperties());
|
|
|
30 |
return javaMailSenderImpl;
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
private Properties getJavaMailProperties(){
|
|
|
34 |
final Properties properties=new Properties();
|
|
|
35 |
properties.put(MAIL_TRANSPORT_PROTOCOL, environment.getRequiredProperty(MAIL_TRANSPORT_PROTOCOL));
|
|
|
36 |
properties.put(MAIL_SMTP_AUTH, environment.getRequiredProperty(MAIL_SMTP_AUTH));
|
|
|
37 |
properties.put(MAIL_SMTP_STARTTLS_ENABLE, environment.getProperty(MAIL_SMTP_AUTH));
|
|
|
38 |
properties.put(MAIL_DEBUG, environment.getProperty(MAIL_DEBUG));
|
|
|
39 |
return properties;
|
|
|
40 |
}*/
|
|
|
41 |
}
|