1

I have the following ssmtp.conf file:

root=test@gmail.com
mailhub=smtp.gmail.com:587
hostname=ed424cef9b52
UseTLS=Yes
UseStartTTLS=Yes
AuthMethod=LOGIN
AuthUser=test
AuthPass=test
FromLineOverride=yes
TLS_CA_File=/etc/ssl/certs/ca-certificates.crt

I can connect to 587 gmail port:

telnet smtp.gmail.com 587
Trying 64.233.186.109...
Connected to gmail-smtp-msa.l.google.com.

But when I try to send mail:

/usr/sbin/ssmtp -v test@gmail.com < qq
ssmtp: Cannot open smtp.gmail.com:587

echo test | mailx  -s "testing ssmtp setup" test@gmail.com
send-mail: Cannot open smtp.gmail.com:587
Can't send mail: sendmail process failed with error code 1
  • 1
    UseStartTTLS=Yes is probably wrong, a T too many. – wurtel May 12 '15 at 11:18
  • Yup, shame on me! Now it asking me the App password of Google :-/ – sebelk May 12 '15 at 11:30
  • At gmail it should be port 465. mailhub=smtp.gmail.com:465 – SDsolar Sep 10 '17 at 6:27
  • Here are the proper instructions for what you are trying to do: unix.stackexchange.com/questions/363814/… – SDsolar Oct 9 '17 at 18:24
1

The proper port is 465

Simplest way to send mail with image attachment from command line using gmail?


EXCERPT:

Install ssmtp with the following commands:

sudo apt-get update
sudo apt-get install ssmtp

Then go into /etc/ssmtp and edit ssmtp.conf to look like this:

root=rpi3abc@gmail.com
mailhub=smtp.gmail.com:465
FromLineOverride=YES
AuthUser=rpi3abc@gmail.com
AuthPass=testing123
UseTLS=YES

Send a one-liner like so:

echo "Testing...1...2...3" | ssmtp myusername@gmail.com

Send a formatted text file like so:

cat mymessage | ssmtp myusername@gmail.com

Where mymessage can be formatted to have lines for TO: and SUBJECT: and the body.

TO: abc@def.com
SUBJECT: Testing
     -blank line-
Message body goes here....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.