Sending email in Java
JavaMail is a built-in API for email.
Ask your ISP if the host is running sendmail or equivalent locally (web server host). This can be advantageous to send to sendmail as early as possible. In other words, try "localhost" as the SMTP server name.
Why? JavaMail is a simple SMTP client. It does not handle DNS MX records. It does not have a built-in mail queue capability if the SMTP server is not available. There it defaults to Java infinte DNS cache so that DNS change on SMTP host is not logged in your application (configurable, but one more setting). This is what the local sendmail process (or equivalent) will do.
So if you can send email to local sendmail / equivalent, that can improve the reliability of email delivery. Let's assume local sendmail is running, of course. This is how we are configuring some native applications that use JavaMail to send mail and has fixed all of the above issues.
source to share