Search code examples
javaemailjakarta-mail

javax.mail is not sending mail to external domains in certain scenarios


I am using javax.mail API for sending the mails in a web application, where I am able to send the email to all domains.

In the same application, I am exposing a webservice which will accept the input data and send a email with an attachment. I am using the same code for sending the mails. But, the email is sending only to the internal domain users(Ex: [email protected]) .The email is not sent to external domains (Ex:[email protected]/[email protected]) .

Kindly help me if anybody knows what could be the reason.Please let me know if you need any additional information.


Solution

  • The SMTP relay host is restricting the email which are sent from email address with other domain names(From Address Ex:[email protected] / [email protected]) to an external domain. After using a valid from address([email protected]), I am able to send email to external domain as well.