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;
|
||||
|
||||
@Value("${spring.mail.username}")
|
||||
private String fromAddress;
|
||||
|
||||
@Autowired
|
||||
public EmailClient(
|
||||
JavaMailSender mailSender,
|
||||
@@ -38,6 +35,13 @@ public class EmailClient {
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -32,6 +32,10 @@ spring:
|
||||
baseline-on-migrate: true
|
||||
thymeleaf:
|
||||
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:
|
||||
configuration:
|
||||
|
||||
Reference in new issue
Block a user