Ssmtp: Cannot open mail:25

ssmtp

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
AuthUser=user@gmail.com
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.

Best Answer

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:

root=you@domain.com
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
Related Question