xm
2024-06-14 722af26bc6fec32bb289b1df51a9016a4935610f
提交 | 用户 | 时间
722af2 1 package com.dl.framework.config;
X 2
3 import cn.hutool.extra.mail.MailAccount;
4 import com.dl.framework.config.properties.MailProperties;
5 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
6 import org.springframework.context.annotation.Bean;
7 import org.springframework.context.annotation.Configuration;
8
9 /**
10  * JavaMail 配置
11  *
12  * @author Michelle.Chung
13  */
14 @Configuration
15 public class MailConfig {
16
17     @Bean
18     @ConditionalOnProperty(value = "mail.enabled", havingValue = "true")
19     public MailAccount mailAccount(MailProperties mailProperties) {
20         MailAccount account = new MailAccount();
21         account.setHost(mailProperties.getHost());
22         account.setPort(mailProperties.getPort());
23         account.setAuth(mailProperties.getAuth());
24         account.setFrom(mailProperties.getFrom());
25         account.setUser(mailProperties.getUser());
26         account.setPass(mailProperties.getPass());
27         account.setSocketFactoryPort(mailProperties.getPort());
28         account.setStarttlsEnable(mailProperties.getStarttlsEnable());
29         account.setSslEnable(mailProperties.getSslEnable());
30         account.setTimeout(mailProperties.getTimeout());
31         account.setConnectionTimeout(mailProperties.getConnectionTimeout());
32         return account;
33     }
34
35 }