Allowing your own From header with sSMTP

How to go about setting your own From header using sSMTP

Today I was wrestling with some email issues on a server and decided to install sSMTP as opposed to Sendmail for sending email out to their internal SMTP server.

First thing I should say is that installing it was a real dream compared to the messing around I had previously done with Sendmail and whilst I know it is no longer maintained it seems very solid and does exactly what I need it to.

One thing that perplexed me however was that whilst I was able to change most of the normal headers by simply passing them in using the PHP mail() function I was unable to set the 'From: ' header.

Since sSMTP uses the www-data user when it is running this is who was coming up as the sender, which is very ugly and not very helpful to the user.

Luckily there is a one line fix for this problem, in the ssmtp.conf file (found in my system at /usr/local/etc/ssmtp/ssmtp.conf) add the following line.

FromLineOverride=YES

This will then allow PHP to set whatever From header it wants.

Recent posts View all

WritingGit

How to speed up Rubocop

A small bit of config that could speed up your Rubocop runs

Web Dev

Purging DNS entries

I had no idea you can ask some public DNS caches to purge your domain to help speed things along