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

Web DevProductivity

Keeping on top of website updates

Learn what website updates are, what they entail, why they are important, and how we can help

Freelancing

Getting the most out of your agency

Here are some tips based on years of working with, for, and as an agency on how to get the most out of any work you do.