Last change
on this file since 9dd526f was 9dd526f, checked in by andrejTavchioski <andrej.tavchioski@…>, 2 years ago |
backend refactoring
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[9dd526f] | 1 | package parkup.configs.email;
|
---|
| 2 |
|
---|
| 3 | import org.springframework.beans.factory.annotation.Autowired;
|
---|
| 4 | import org.springframework.context.annotation.Bean;
|
---|
| 5 | import org.springframework.context.annotation.Configuration;
|
---|
| 6 | import org.springframework.core.env.Environment;
|
---|
| 7 | import org.springframework.mail.javamail.JavaMailSender;
|
---|
| 8 | import org.springframework.mail.javamail.JavaMailSenderImpl;
|
---|
| 9 |
|
---|
| 10 | import java.util.Properties;
|
---|
| 11 |
|
---|
| 12 | @Configuration
|
---|
| 13 | public class MailConfig {
|
---|
| 14 |
|
---|
| 15 | @Autowired
|
---|
| 16 | private Environment env;
|
---|
| 17 |
|
---|
| 18 | @Bean
|
---|
| 19 | public JavaMailSender getMailSender() {
|
---|
| 20 | JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
---|
| 21 |
|
---|
| 22 | mailSender.setHost(env.getProperty("spring.mail.host"));
|
---|
| 23 | mailSender.setPort(Integer.valueOf(env.getProperty("spring.mail.port")));
|
---|
| 24 | mailSender.setUsername(env.getProperty("spring.mail.username"));
|
---|
| 25 | mailSender.setPassword(env.getProperty("spring.mail.password"));
|
---|
| 26 |
|
---|
| 27 | Properties javaMailProperties = new Properties();
|
---|
| 28 | javaMailProperties.put("mail.smtp.starttls.enable", "true");
|
---|
| 29 | javaMailProperties.put("mail.smtp.auth", "true");
|
---|
| 30 | javaMailProperties.put("mail.transport.protocol", "smtp");
|
---|
| 31 | javaMailProperties.put("mail.debug", "true");
|
---|
| 32 |
|
---|
| 33 | mailSender.setJavaMailProperties(javaMailProperties);
|
---|
| 34 | return mailSender;
|
---|
| 35 | }
|
---|
| 36 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.