Linux configuration -- ssmtp: Cannot open smtp.gmail.com:587

I encountered the same problem. The following steps worked for me:

  1. sudo vi /etc/ssmtp/ssmtp.conf Add the following:

TLS_CA_FILE=/etc/pki/tls/certs/ca-bundle.crt [email protected] mailhub=smtp.gmail.com:587 AuthUser=XXXX AuthPass=XYXYX UseSTARTTLS=Yes UseTLS=Yes hostname=AAAA

Replace: XXXX- username(mail) XYXYX- password(mail password) AAAA- hostname(get by running $hostname)

  1. sudo vi /etc/ssmtp/revaliases Add the following:

root:[email protected]:smtp.gmail.com:587

Replace : XXXX - username(mail)

  1. Try running the mail now:

    $mail -s "adasdas" [email protected]

    CC: XYZLoremIpsum . 'ctrl+D'

It solved my problem. Hopefully for a system(Office) you need to configure correct proxy settings otherwise you will get an error:

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


try changing this option

Allowing less secure apps to access your account

https://support.google.com/accounts/answer/6010255?hl=en


This is perhaps because you're not setting the hostname parameter of ssmtp.conf. It should be a resolvable, fully-qualified domain name; yours is defaulting to the machine name of ctmtest (as shown in the EHLO command that you quote above).

The issue that user963 mentions in their answer may also be in action here, but in that case you'll get a different error message, something like ssmtp: Authorization failed (534 5.7.14 ...).