sSMTP: Cannot open smtp server

10,020

Solution 1

Either

  • disable TLS and / or StartTLS in your ssmtp config

or

  • fix TLS and / or StartTLS on mail.mymailhost.com.

Solution 2

  1. Log in with the gmail account you want to send mail as and switch on "Allow less secure apps". Here is the link https://myaccount.google.com/lesssecureapps?pli=1

  2. In my /etc/ssmtp/ssmtp.conf file I have the following. Notice UseTLSCert=YES and UseTLS=YES are commented out? I fiddled until it started working. I don't know why it works like this, but anyway this is what I did.

[email protected]
mailhub=smtp.gmail.com:587
Hostname=localhost
[email protected]
AuthPass=xxx
FromLineOverride=YES
RewriteDomain=gmail.com
#UseTLS=YES
#UseTLSCert=YES
UseSTARTTLS=YES
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
  1. I then used this page to know how to use ssmtp https://tecadmin.net/send-email-smtp-server-linux-command-line-ssmtp/
Share:
10,020

Related videos on Youtube

ForceMagic
Author by

ForceMagic

Updated on September 18, 2022

Comments

  • ForceMagic
    ForceMagic over 1 year

    This is not a duplicate, I'm aware of the other question and it didn't help me.

    Here's my ssmtp.conf:

    [email protected]
    rewriteDomain=mydomain.com
    hostname=myHostnameHere
    FromLineOverride=YES
    [email protected]
    AuthPass=myPasswordHere
    AuthMethod=LOGIN
    FromLineOverride=YES
    mailhub=mail.mymailhost.com:465
    UseSTARTTLS=YES
    UseTLS=YES
    TLS_CA_Dir=/usr/share/ca-certificates/mozilla/
    

    I also tried telnet-ing to the server, and it worked, so the port and the host are correct (here it is redacted).

    The problem is:

    sSMTP[{PID}]: STARTTLS not working
    sSMTP[{PID}]: Cannot open mail.mymailhost.com:465
    

    Executed command: echo "This is a test" | mail -s "Test" [email protected]

    Response: mail: cannot send message: Process exited with a non-zero status

    OS: debian

    • gxx
      gxx almost 8 years
      What did you do to (try to) solve the problem?
    • ForceMagic
      ForceMagic almost 8 years
      I tried settings UseTLS and StartTLS to no with all variations, but no luck. Your answer worked.
  • ForceMagic
    ForceMagic almost 8 years
    Disabled both of TLS and StartTLS settings. It works! Thanks!
  • gxx
    gxx almost 8 years
    @ForceMagic Think about if you really would like to go this route because of the security implications. Maybe it would be wise to investigate the second point I've raised. Good luck!
  • ForceMagic
    ForceMagic almost 8 years
    Oh, I don't own the mail host. So I can't really do anything about it. But anyways, thanks again :)
  • ForceMagic
    ForceMagic almost 8 years
    also one more question... I want to know how to setup [email protected] as the email sender instead of [email protected]
  • gxx
    gxx almost 8 years
    @ForceMagic No idea, sorry. I'm quite sure this is described in the docs. If you're unable to solve this on your own, post a new question.