Search code examples
sslsmtptls1.2starttls

Error: com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 : Recipient address rejected: SASLUsername Domain and Sender Domain Are Differnet


I am tying to send email using JavaMailSender. I am able to send email to my gmail account using this configuration.

mail:
        host: smtp.gmail.com
        port: 587
        username: xyz*****@gmail.com
        password: ***************
        protocol: smtp
        properties.mail.smtp:
            auth: true
            starttls.enable: true
            ssl.trust: smtp.gmail.com

But when I use another server with the following config I get this error : "com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 **********@gmail.com: Recipient address rejected: SASLUsername Domain and Sender Domain Are Differnet - Sender Blocked"

mail:
        host: mail.xyz***xyz.com
        port: 25 (or 587)
        username: noreply@xyz***xyz.com
        password: **************
        protocol: smtp
        properties.mail.smtp:
            auth: true
            starttls.enable: false
            ssl.trust: mail.xyz***xyz.com
            sockeFactory.class: javax.net.ssl.SSLSocketFactory
            ssl.protocols: TLSv1

When I change starttls.enable: true I get error: javax.mail.MessagingException: Could not convert socket to TLS; nested exception is: javax.net.ssl.SSLHandshakeException: Certificates do not conform to algorithm constraints

After I remove sockeFactory.class: javax.net.ssl.SSLSocketFactory and ssl.protocols: TLSv1 I get Error : the-server-selected-protocol-version-tls10-is-not-accepted-by-client-preferences

Can anyone help me out resolving these configurational issues.


Solution

  • This is happening because Zimbra has a setting which ensures that the credentials used for sending and authentication need to be same. Please check your code to ensure that your javamail From and auth are using the same email address. This should solve the error.