When a script, or user sends email via ssmtp, it appears to come from root@gmail.com, resulting in emails always ending up in spam folders. Even if trained and marked as non-spam. This causes one to miss important system messages. Below causes the email to appear to come from a legit email, fixing this annoying and dangerous problem.
There are a couple of settings in ssmtp that can be manipulated to allow a change in the 'From' field of emails: 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. 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:your_login@your.domain: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 outgoingmessages and (optionally) the mailhub these messages will be sentthrough. Example: root:jdoe@isp.com:mail.isp.comMessages root sends will be identified as from jdoe@isp.com and sentthrough mail.isp.com.
The sending command line should look like this:
printf "From: Sysadmin <johann.maxen@gmail.com>\nSubject: Server room aircon alert\n\nTEMPERATURE THRESHOLD EXCEEDED: %uC\n" $temp| /usr/local/sbin/ssmtp \ johann.maxen@gmail.com, johann.swart@up.ac.za |