5

I am trying to configure ssmtp on our Ubuntu 12.04 server. However I had no luck so far. My ssmtp.conf looks like this:

[email protected]
mailhub=mail.server.com:25
rewriteDomain=
hostname=hostname.server.com
AuthUser=me
AuthPass=mypassword
UseTLS=YES
FromLineOverride=YES

When I try to send mails I get ssmtp: Cannot open mailhub:25. When I use sudo the error message reads a little different ssmtp: Cannot open mail.server.com:25 The server should normally accept SMTP on port 25 and I can contact it with telnet mail.server.com 25. Any ideas would be greatly appreciated.

n1000
  • 261
  • 1
  • 2
  • 10

2 Answers2

11

Ok I figured it out... I had to use UseSTARTTLS=YES instead of UseTLS=YES. Also I had to enter root:[email protected]:mail.server.com:25in /etc/ssmtp/revaliases. Hope this helps others as well.

If you want to use other user accounts than root, you will have to add those to /etc/ssmtp/revaliases as well and add them to the 'mail' group.

n1000
  • 261
  • 1
  • 2
  • 10
  • 1
    the part about /etc/ssmtp/revaliases was quite useful. In my case (not using gmail) I had to use UseTLS=YES *instead* of UseSTARTTLS=YES and not the other way around. Looking into /var/log/mail.log helped me find that out. (Ubuntu 20.04, inmotionhosting.com mail server) – Louis Gagnon Sep 11 '20 at 07:39
8

There is another case, which I encountered, where this happens: If you remove read access to ssmtp.conf from others because you don't want the password to be visible to all users, then you will get the same error unless your account has read access to that file. For example, when trying sendmail you might have to do sudo sendmail instead.

gablin
  • 263
  • 2
  • 6
  • 1
    This solved this for me. Seems like a different method could be to change the group of the ssmtp.conf file to "mail" or something, then add your user there, and `chmod g+r` that file. – Hut8 Jan 29 '16 at 16:44
  • 4
    For a secure way to grant appropriate permissions, see here: https://wiki.archlinux.org/index.php/SSMTP#Security – Tyler Apr 05 '16 at 02:37