ssmtp Cannot open mail.server.com:25
Solution 1
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:25
in /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.
Solution 2
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.
Related videos on Youtube
n1000
Updated on September 18, 2022Comments
-
n1000 over 1 year
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 differentssmtp: Cannot open mail.server.com:25
The server should normally accept SMTP on port 25 and I can contact it with telnetmail.server.com 25
. Any ideas would be greatly appreciated.-
fkraiem over 9 yearsHow are you trying to send mail?
-
n1000 over 9 years
ssmtp [email protected] < mail.txt
andssmtp [email protected]
-
fkraiem over 9 yearsMaybe try
mailx [email protected] < mail.txt
. Also, anything interesting in/var/log/mail.log
? -
n1000 over 9 yearsMailx is not installed. Without sudo:
/etc/ssmtp/ssmtp.conf not found
,Unable to locate mailhub
, with sudo:SSL connection using (null)
-
Sergiy Kolodyazhnyy over 9 yearsAt least in case with my mailhub I had to use port 587 because 25 was constantly blocked. Try this one out, also see if you mail server can be accessed from another port. Also , last resort could be to switch to msmtp. That's what I have now
-
Sergiy Kolodyazhnyy over 9 yearsYou said mailx isn't installed. I'm not 100% sure , but you'd need mailutils installed to do anything with mail. Do that
-
n1000 over 9 yearsThanks! Same issue on 25 and 587. telnet working for both. other ports are blocked. mailutils did not help :(
-
-
Edu over 8 yearsThis 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. -
Tyler about 8 yearsFor a secure way to grant appropriate permissions, see here: wiki.archlinux.org/index.php/SSMTP#Security
-
Louis Gagnon over 3 yearsthe 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)