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:

[root@prism ~]# uname -a
FreeBSD prism.local 11.0-RELEASE-p9 FreeBSD 11.0-RELEASE-p9 #0: Tue Apr 11 08:48:40 UTC 2017  amd64

First disable sendmail (insert this into /etc/rc.conf):


And ensure that sendmail is no longer running:

killall sendmail

Now install (I use pkg) ssmtp:

[root@prism ~]# pkg install ssmtp

And then to replace sendmail with ssmtp change your /etc/mail/mailer.conf to:

sendmail	/usr/local/sbin/ssmtp
send-mail	/usr/local/sbin/ssmtp
mailq		/usr/local/sbin/ssmtp
newaliases	/usr/local/sbin/ssmtp
hoststat	/usr/bin/true
purgestat	/usr/bin/true

To use Google’s smtp, you need to:

  • Create an App-password for you GMail account
  • Modify /usr/local/etc/ssmtp/ssmtp.conf

Goto to create an App-password for the server to use your account.

And insert/uncomment something like this into the /usr/local/etc/ssmtp/ssmtp.conf:

You should now be able to send mails from the commandline:

mail -v -s "test subject"

I also created a .forward file in /root/ with the to-email where I wanted all my system mail to go.

No comments, so go and ... add one

Speak Your Mind

Your email address will not be published. Required fields are marked *