【发布时间】:2020-09-07 21:41:47
【问题描述】:
尝试通过我的 Spring Boot 应用程序发送电子邮件时出现此错误:
failures; nested exception is javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
java.net.SocketException: Software caused connection abort: socket write error. Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1);
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
我的 Spring boot 应用程序是使用 jhipster 生成的,这是我的邮件配置的 application-dev.yml 配置:
mail:
host: mail.example.com
port: 587
username: support@example.com
password: ************
注意:example.com 只是一个不共享机密数据的示例,我的配置是正确的,我已经对其进行了测试并且效果很好,但在我的 Spring Boot 应用程序上却没有
【问题讨论】:
-
您需要使用实际的SMTP配置,example.com不存在。
-
我当然做到了!!! example.com 只是一个不共享机密数据的例子,谢谢你的评论,伙计
-
为什么将其标记为 jhipster?这只是 spring-boot 配置。您的问题缺少一些细节,例如您的邮件服务器(公共或私人)是什么?您是否使用
telnet命令或邮件客户端测试过您的配置?您只显示了您的应用程序属性的摘录,所以我们不知道它是否正确缩进并且在spring下,它可以是什么?你有没有在调试器中设置断点来检查MailProperties的内容? -
感谢您的回答,您是对的,没有必要在该问题上标记 jhipster,因为您说这是一个 spring-boot 配置问题。我确实按照你所说的进行了测试,我发现我忘记添加'mail.smtp.starttls.enable:true'和'mail.smtp.starttls.auth:true'向你致以最诚挚的问候@GaëlMarziou
标签: java spring-boot smtp