How to change default FROM address for mail command using sSMTP?

There are a couple of settings in ssmtp that can be manipulated to allow a change in the 'From' field of emails:

  1. There is a setting within /etc/ssmtp/ssmtp.conf. By default the system selects the 'From' address but this can be altered by unchecking the FromLineOverride line:

    # Are users allowed to set their own From: address?
    # YES - Allow the user to specify their own From: address
    # NO - Use the system generated From: address
    #FromLineOverride=YES
    

    By 'unchecking' I mean remove the hash mark at the beginning of that particular line.

  2. There can be settings within /etc/ssmtp/revaliases to allow a specific 'From' line from each user. The example given in revaliases is reasonably unhelpful:

    # Example: root:[email protected]:mailhub.your.domain[:port]
    # where [:port] is an optional port number that defaults to 25.
    

    But the man pages gives a much more explicit example:

    A reverse  alias  gives  the From: address placed on a user's outgoing
    messages and (optionally) the  mailhub  these  messages  will  be  sent
    through. Example:
    
     root:[email protected]:mail.isp.com
    
    Messages  root  sends  will be identified as from [email protected] and sent
    through mail.isp.com.
    

I personally do not use ssmtp instead I use msmtp where the syntax for altering the 'From' field is a lot simpler and can be contained in the file $HOME/.msmtprc:

from [email protected]

which is a lot easier...

References:

  • Arch Wiki: ssmtp