修改邮件发送问题

This commit is contained in:
walker-sheng 2020-12-30 09:17:22 +08:00
parent 3d7fd9a5c2
commit 1745fcd5e0
2 changed files with 44 additions and 3 deletions

View File

@ -0,0 +1,40 @@
package club.joylink.rtss.configuration.configProp;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix="spring.mail")
public class MailConfig {
private String host;
private String username;
private String password;
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.services;
import club.joylink.rtss.configuration.configProp.MailConfig;
import club.joylink.rtss.configuration.configProp.OtherConfig;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.constants.EmailSubject;
@ -29,8 +30,8 @@ public class EmailService implements IEmailService {
@Autowired
private JavaMailSender mailSender; //自动注入的Bean
// @Autowired
// private MailConfig mailConfig;
@Autowired
private MailConfig mailConfig;
@Autowired
private ISysUserService sysUserService;
@ -41,7 +42,7 @@ public class EmailService implements IEmailService {
@Override
public void sendToOne(String toUser, String subject, String content) {
SimpleMailMessage smm = new SimpleMailMessage();
// smm.setFrom(this.mailConfig.getUsername());
smm.setFrom(this.mailConfig.getUsername());
smm.setTo(toUser);
smm.setSubject(subject);
smm.setText(content);