Categories
Linux Miscellaneous Shell

Using sendmail with a Relay Host

It is useful when Docker containers can send e-mail to you in case there is an error condition that needs attention. Here is how to.

Install the sendmail package from your distribution and edit the file /etc/mail/sendmail.mc. Add this line to the end of it:

define('SMART_HOST', '<dns-name-of-your-relay')

Done! Just restart sendmail:

/etc/init.d/sendmail stop
/etc/init.d/sendmail start
Categories
Java Linux

JavaMail: Sending mails fails

Ever stumbled across this?

javax.mail.SendFailedException: Sending failed;
   nested exception is:
      javax.mail.MessagingException: 501 5.0.0 HELO requires domain address

I wasn’t able for a long time to find the solution in the net although many people reported having this problem. The only hint you find is “There was an invalid entry in /etc/hosts”. But noone said exactly what the “invalid entry” was.

I myself found that there was no invalid entry but the configured hostname of the machine (issue “hostname” in a shell) cannot be resolved by DNS. The result is the given error message from the mail server.

What is happening? JavaMail resolves its own hostname by asking for the local hostname. The SMTP protocol requires the sending domain while handshaking. The server will try to resolve the domain by its DNS. If the hostname sent cannot be resolved then the server responds with “HELO requires domain address” as stated above.

I hope that this issue now becomes clearer to all of you.

PS: Solution is make sure your hostname can be resolved by DNS. Fix your hostname if it’s wrong or add the DNS entry.

Categories
Miscellaneous

SMTP and POP servers

There is a great SMTP/POP server list in case you need to configure around some of them:

http://www.patshaping.de/hilfen_ta/pop3_smtp.htm