Using ssmtp instead of sendmail
I had problems with my mails from my server got categorized as spam in GMail :-(
So I decided to use Google's smtp gateway for sending the mails ...
I run FreeBSD:
1[root@prism ~]# uname -a 2FreeBSD prism.local 11.0-RELEASE-p9 FreeBSD 11.0-RELEASE-p9 #0: Tue Apr 11 08:48:40 UTC 2017 firstname.lastname@example.org:/usr/obj/usr/src/sys/GENERIC amd64
sendmail (insert this into
1sendmail_enable="NO" 2sendmail_submit_enable="NO" 3sendmail_outbound_enable="NO" 4sendmail_msp_queue_enable="NO"
And ensure that
sendmail is no longer running:
Now install (I use
1[root@prism ~]# pkg install ssmtp
And then to replace
ssmtp change your
1sendmail /usr/local/sbin/ssmtp 2send-mail /usr/local/sbin/ssmtp 3mailq /usr/local/sbin/ssmtp 4newaliases /usr/local/sbin/ssmtp 5hoststat /usr/bin/true 6purgestat /usr/bin/true
To use Google's
smtp, you need to:
- Create an App-password for you GMail account
Goto apppasswords to create an App-password for the server to use your account.
And insert/uncomment something like this into the
1mailhub=smtp.gmail.com:587 2AuthUseremail@example.com 3AuthPass=yournewapppassword 4rewriteDomain=yourdomain.dk 5FromLineOverride=YES 6UseSTARTTLS=YES
You should now be able to send mails from the commandline:
1mail -v -s \"test subject\" firstname.lastname@example.org
I also created a
.forward file in
/root/ with the to-email where I wanted all my system mail to go.