问题
I'm trying to send an email from a spring boot application with spring mail (1.5.8.RELEASE) JavaMailSender
sending through gmail SMTP is fine. however sending email through my domain registrar's amtp (registrar name- 1and1, in case someone already worked this out) is not working.
I'm getting this error, which imo - is more generic than useful: com.sun.mail.smtp.SMTPSenderFailedException: 550-Requested action not taken: mailbox unavailable 550 invalid DNS MX or A/AAAA resource record
domain I'm sending through is bank.org, and has this DNS settings:
bank.org. 3600 IN A 178.79.161.205
bank.org. 3600 IN MX 11 mx01.1and1.com.
bank.org. 3600 IN MX 10 mx00.1and1.com.
the issue is, I'm able to send emails to gmail with the settings specified in this guide: http://www.baeldung.com/spring-email
these are settings to send with gmail:
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
However when i try to send messages via my registrar these settings are not successful:
spring.mail.host=smtp.1and1.com
spring.mail.port=587
spring.mail.username=username
spring.mail.password=password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
thew issue is - I am able to connect to the 1and1 SMTP using thunderbird email client. so I know the credentials are working.
I guess what I need is to find out a way to detect the correct settings because the support team can't assist with issues related to sending email programmatically from spring mail
回答1:
the cause of the issue was - I didn't programmatically set the sender field (The "From" field) in my outgoing message
Once i set the From field the issue was resolved.
unfortunately the response from 1and1's SMTP was irrelevant ("550 invalid DNS MX or A/AAAA resource record")
Hope this helps anyone
来源:https://stackoverflow.com/questions/47044257/trouble-with-sending-mail-with-spring-mail-through-somain-registrar-1and1-smtp