10

I've installed ssmtp and then edited the ssmtp.conf file so could try sending a mail but says cannot open mail:25 however in the conf file I set it to gmail port 467 and I am pretty sure everything else is right.

What specifically do I need to look for with this error or could it be any number of settings in and outside of the configuration file?

#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
# See the ssmtp.conf(5) man page for a more verbose explanation of the
# available options.
#

# The person who gets all mail for userids < 500
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=mail

# Example for SMTP port number 2525
mailhub=smtp.gmail.com:465
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?
#RewriteDomain=

# The full hostname
#Hostname=

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
#FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
UseTLS=YES
UseSTARTTLS=YES
[email protected]
AuthPass=xxxxxx

# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

# Use this RSA certificate.
#TLSCert=/etc/pki/tls/private/ssmtp.pem
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES

Interestingly all the files in /etc/pki/tls/certs/ are the exact same ones I deleted in my /etc/ssl folder! haha Now I know a certain amount of business happened when creating an untrusted cert.

9
  • Does your firewall blocks the port 25
    – Nidal
    Jun 7, 2014 at 14:17
  • I don't know, is that the only possibility?
    – cea
    Jun 7, 2014 at 14:30
  • 2
    Seeing the complete configuration file would help to solve the issue. Jun 7, 2014 at 15:18
  • 1
    @cea: once again (as in the Apache + ssl.conf) question you give too little information. The error message indicates it's trying to contact a host named mail on port 25. Does the name mail resolve (use host, nslookup or getent hosts mail to verify)? Coincidentally mailhub=mail is the default setting in the config file. It would also be good to know what you expect to achieve by connecting to port 467 with "gmail" (which host????). On another note: have you tried nullmailer? Jun 7, 2014 at 15:20
  • 1
    ssmtp does NOT verify the SSL/TLS certificate of the remote server on the current debian, ubuntu and redhat releases and also does NOT verify the hostname of the certificate. This is a major issue, as this effectively renders the encryption useless and your password is being transmitted alike to being plaintext and anyone can sniff it. ssmtp has had no active development since atleast 2009. So, if you care about the security of the email account you use for your servers outgoing emails, do NOT use ssmtp, but postfix (or something else) instead: unix.stackexchange.com/a/118101/72087
    – Zulakis
    Feb 24, 2016 at 10:42

3 Answers 3

4

The first uncommented mailhub=mail would seem to be the cause for this.

Without an FQDN and a port number, I imagine it configures ssmtp to attempt to connect on port 25 to a host called mail in your default domain (however you have that set up locally) which presumably does not exist.

1
  • @RuiFRibeiro Thanks for the feedback; updated with a brief explanation.
    – tripleee
    May 23, 2017 at 4:36
4
ssmtp: Cannot open mail:25 

can be caused by file permission errors on /etc/ssmtp/ssmtp.conf. Whatever application is trying to run ssmtp cannot read the file.

chmod 640 /etc/ssmtp/ssmtp.conf
chown root:mail /etc/ssmtp/ssmtp.conf

& add the application sending email to the mail group (e.g logcheck if it is not part of adm group)

For completeness your smtp.conf should look something like:

[email protected]
mailhub=your-mailserver.com:465
#mailhub=gmail.com:587 ### -> note 587 for STARTTLS
hostname=your-vps.com
UseTLS=Yes
#UseSTARTTLS=Yes ### => gmail needs this (not all servers do)
AuthUser=xxxxxx
AuthPass=xxxxxx
FromLineOverride=NO
#Debug=YES

# on Fedora / Red Hat / or with ssmtp-validate-TLS-server-cert.patch
TLS_CA_File=/etc/ssl/certs/ca-certificates.crt
1
0

The same thing happened to me!!

No answer on the internet has given me the desired result.

Make sure you've installed all the required repos and packages before sending the mail using ssmtp.

Try executing these commands.. After this,it really worked for me!!

mv /usr/sbin/sendmail /usr/sbin/sendmail.ORIG
ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
2
  • Where did you get the idea to do this?  Can you explain why it might help? … … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete. Apr 11, 2022 at 20:56
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Apr 18, 2022 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .