Allowing your own From header with sSMTP

How to go about setting your own From header using sSMTP

2025 Update: According to the Debian wiki the sSMTP project has been unused since 2019 and the recommendation is to use msmtp instead.

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

JavaScript

Setting a more specific database type in Prisma

Prisma sets a default of TEXT for all String fields, here is how you can override that.

Ruby

Override database attribute types

Sometimes you don't have control over how your database handles information, so you need Rails to set it