sSMTP: Cannot open smtp server
Solution 1
Either
- disable
TLS
and / orStartTLS
in yourssmtp
config
or
- fix
TLS
and / orStartTLS
onmail.mymailhost.com
.
Solution 2
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
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
- I then used this page to know how to use ssmtp https://tecadmin.net/send-email-smtp-server-linux-command-line-ssmtp/
Related videos on Youtube
ForceMagic
Updated on September 18, 2022Comments
-
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 almost 8 yearsWhat did you do to (try to) solve the problem?
-
ForceMagic almost 8 yearsI tried settings
UseTLS
andStartTLS
to no with all variations, but no luck. Your answer worked.
-
-
ForceMagic almost 8 yearsDisabled both of TLS and StartTLS settings. It works! Thanks!
-
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 almost 8 yearsOh, I don't own the mail host. So I can't really do anything about it. But anyways, thanks again :)
-
ForceMagic almost 8 yearsalso one more question... I want to know how to setup
[email protected]
as the email sender instead of[email protected]
-
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.