mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-25 06:57:13 +08:00
@@ -62,6 +62,11 @@ public class MailConfig {
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 发件人
|
||||
*/
|
||||
private String from;
|
||||
|
||||
/**
|
||||
* 是否启用 SSL 连接
|
||||
*/
|
||||
@@ -121,6 +126,14 @@ public class MailConfig {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public boolean isSslEnabled() {
|
||||
return sslEnabled;
|
||||
}
|
||||
@@ -157,6 +170,7 @@ public class MailConfig {
|
||||
public Properties toJavaMailProperties() {
|
||||
Properties javaMailProperties = new Properties();
|
||||
javaMailProperties.putAll(this.getProperties());
|
||||
javaMailProperties.put("mail.from", this.getFrom());
|
||||
javaMailProperties.put("mail.smtp.auth", true);
|
||||
javaMailProperties.put("mail.smtp.ssl.enable", this.isSslEnabled());
|
||||
if (this.isSslEnabled()) {
|
||||
|
@@ -164,7 +164,8 @@ public class MailUtils {
|
||||
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8
|
||||
.displayName());
|
||||
// 设置基本信息
|
||||
messageHelper.setFrom(mailSender.getUsername());
|
||||
messageHelper.setFrom(CharSequenceUtil.blankToDefault(mailSender.getJavaMailProperties()
|
||||
.getProperty("mail.from"), mailSender.getUsername()));
|
||||
messageHelper.setSubject(subject);
|
||||
messageHelper.setText(content, isHtml);
|
||||
// 设置收信人
|
||||
|
Reference in New Issue
Block a user