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