fix(mail): add base smtp config for mail sender
- Configure a default SMTP host and username so the JavaMailSender bean is always created - Move from-address injection from a field to a setter
This commit is contained in:
2 files changed
+11
-3
No files matched your search
@@ -26,9 +26,6 @@ public class EmailClient {
|
|||||||
|
|
||||||
private final TemplateEngine emailTemplateEngine;
|
private final TemplateEngine emailTemplateEngine;
|
||||||
|
|
||||||
@Value("${spring.mail.username}")
|
|
||||||
private String fromAddress;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public EmailClient(
|
public EmailClient(
|
||||||
JavaMailSender mailSender,
|
JavaMailSender mailSender,
|
||||||
@@ -38,6 +35,13 @@ public class EmailClient {
|
|||||||
this.emailTemplateEngine = emailTemplateEngine;
|
this.emailTemplateEngine = emailTemplateEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String fromAddress;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setFromAddress(@Value("${spring.mail.username}") String fromAddress) {
|
||||||
|
this.fromAddress = fromAddress;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a template-based HTML email asynchronously.
|
* Send a template-based HTML email asynchronously.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ spring:
|
|||||||
baseline-on-migrate: true
|
baseline-on-migrate: true
|
||||||
thymeleaf:
|
thymeleaf:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
mail:
|
||||||
|
# This configuration is used to suppressing warnings of no beans found of JavaMailSender.
|
||||||
|
host: example.smtp.com
|
||||||
|
username: app@dfguide.onixbyte.cn
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
configuration:
|
configuration:
|
||||||
|
|||||||
Reference in new issue
Block a user