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:
zihluwang committed 2026-08-19 14:10:41 +08:00
1 parent d9b74ae2e3
commit 4d9bf64ef4
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.
*
+4
View File
@@ -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: