How to get ssmtp to map local user to email address for the To: field

I have struggled a bit with ssmtp too. The first thing I learned is that the aliases mechanism does not work with the plain mail program; I have to use mailx from the package bsd-mailx — never knew why. So before starting to change configurations around check with it.

Anyway, as a reference, I have a working ssmtp setup like the following:

  1. file /etc/ssmtp/ssmtp.conf:

    #
    # Config file for sSMTP sendmail
    #
    # The person who gets all mail for userids < 1000
    # Make this empty to disable rewriting.
    [email protected]
    
    # The place where the mail goes. The actual machine name is required no 
    # MX records are consulted. Commonly mailhosts are named mail.domain.com
    mailhub=mymailserver.mymail.domain.com:25
    
    # Where will the mail seem to come from?
    rewriteDomain=mymail.domain.com
    
    # The full hostname
    hostname=myhostname.mymail.domain.com
    # Use SSL/TLS before starting negotiation 
    UseTLS=No
    #UseSTARTTLS=Yes
    #
    # 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=NO
    
  2. file /etc/ssmtp/revaliases/

    # sSMTP aliases
    # 
    # Format:   local_account:outgoing_address:mailhub
    #
    # Example: root:[email protected]:mailhub.your.domain[:port]
    # where [:port] is an optional port number that defaults to 25.
    #
    root:[email protected]
    romano:[email protected]
    postmaster:[email protected]
    

and now it works:

[romano:~] % mailx -v root
Subject: test
test
.
Cc: 
[<-] 220 mymailserver.mymail.domain.com ESMTP my mail server
[->] HELO myhostname.mymail.domain.com
[<-] 250 mymailserver.mymail.domain.com
[->] MAIL FROM:<[email protected]>
[<-] 250 2.1.0 Ok
[->] RCPT TO:<[email protected]>
[<-] 250 2.1.5 Ok
[->] DATA
[<-] 354 End data with <CR><LF>.<CR><LF>
[->] Received: by myhostname.mymail.domain.com (sSMTP sendmail emulation); Fri, 03 Jul 2015 13:25:52 +0200
[->] From: "Romano Giannetti" <[email protected]>
[->] Date: Fri, 03 Jul 2015 13:25:52 +0200
[->] To: root
[->] Subject: test
[->] 
[->] test
[->] .
[<-] 250 2.0.0 Ok: queued as BF1CB3BC050
[->] QUIT
[<-] 221 2.0.0 Bye

Notice that domains, hostnames etc. are scrambled for privacy here (so there can be typoes).