spring-boot-mail
2019-01-29 13:40:43 14 举报
AI智能生成
spring-boot-starter-mail 笔记
作者其他创作
大纲/内容
Sending Emails with Attachments
Simple Email Template
Handling Send Errors
常见错误
javax.mail.AuthenticationFailedException:
535 5.7.3 Authentication unsuccessful
535 5.7.3 Authentication unsuccessful
账号密码错误
javax.mail.AuthenticationFailedException:
No authentication mechanisms supported by both server and client
No authentication mechanisms supported by both server and client
spring.mail.propertes.mail.auth.mechanisms: NTLM
com.sun.mail.smtp.SMTPSendFailedException: 501 5.1.7 Invalid address
没有设置mail.from
javax.mail.MessagingException: STARTTLS is required but host does not support STARTTLS
Mail server 不支持TLS
References
https://docs.spring.io/spring-boot/docs/1.5.13.RELEASE/reference/htmlsingle/#boot-features-email
https://docs.spring.io/spring/docs/5.1.4.RELEASE/spring-framework-reference/integration.html#mail
https://www.baeldung.com/spring-email
Dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
interfaces and classes
MailSender
interface
JavaMailSender
interface
JavaMailSenderImpl
class
MailMessage
interface
SimpleMailMessage
class
MimeMessagePreparator
interface
MimeMessageHelper
class
Properties
Spring
SpringBoot
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=<login user to smtp server>
spring.mail.password=<login password to smtp server>
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.port=587
spring.mail.username=<login user to smtp server>
spring.mail.password=<login password to smtp server>
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
/META-INF/javamail.default.providers
Sending Simple Emails
0 条评论
下一页