I'm using ssmtp for sending email (the setting is below)

Now when i run a cron command or an at command, mail is sent to


which is username @ machinename

Now ofcourse this is not a valid email address, so i get errors in my gmail saying: can't send email to michel@mypi

How and where should i say that email to the user 'michel' should go to a particular email address?

The setting for ssmtp:

# 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

# Where will the mail seem to come from?

# The full hostname

# 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 
  • How does gmail fit into this description?
    – tink
    Commented Mar 25, 2013 at 20:08
  • ehm, i'm using the gmail account to send email with ssmtp
    – Michel
    Commented Mar 25, 2013 at 20:21
  • Ah, the error in my gmail is because I configured ssmtp to send email via gmail (see the config in the question) and for some reason the engine which sends email on behalf of cron uses that setting too, and so when cron sends email to michel@mypi it is sent back to my gmail account saying it can not send email to michel@mypi
    – Michel
    Commented Mar 25, 2013 at 21:20
  • 2
    @Michel ssmtp doesn't do local mail. If you want local mail and smart host sending, you will want a real MTA such as exim4 or postfix, which can do both.
    – jordanm
    Commented Mar 25, 2013 at 21:38
  • 1
    @jordanm Yeah, i just noticed 1 minute ago that the MyPi were the mail goes to wasn't the machine name, but the hostname setting from the ssmtp config (which had the same value as my machine name). What ssmtp seems to do is to add the setting in the hostname to the local user name and use that as an email address. I tried exim4 once and i couldn't get it to work, and I'm afraid to reset my mail install just for this issue. Is there a way to workaround this? Say let ssmtp ignore local mail, or don't let cron and at send email?
    – Michel
    Commented Mar 25, 2013 at 21:45

3 Answers 3


Sorry to raise the dead, but I stumbled across this via Google and have just solved it: the /etc/ssmtp/revaliases is only the aliases for the FROM: addresses.

Aliases for TO: addresses would normally need to be set in /etc/aliases, but SSMTP doesn't read this! Instead, you need to edit /etc/mail.rc and add a line such as

alias root root<[email protected]>

See http://possiblelossofprecision.net/?p=591 for more info.

UPDATE 2019-05-07 - According to comments below, the later versions of the package that are now in EPEL (if you're on RedHat family distros) now do read the /etc/aliases file, so check your version!

  • 1
    No need to apologise - it's great that you post a solution, it will help anyone else who tries to use this and runs into the same problem!
    – Jenny D
    Commented Apr 14, 2014 at 14:02
  • 1
    This was it! I think most of the other guides that mention revaliases work because the uid being sent to is <1000 and the root address just collects all of them.
    – psp
    Commented Dec 20, 2015 at 16:37
  • you are my hero
    – Greg Flynn
    Commented Jan 25, 2017 at 21:31
  • 1
    Just a note that ssmtp version 2.64 which is in the EPEL repo for CentOS 7 does in fact use /etc/aliases instead of /etc/mail.rc.
    – sdragnev
    Commented Mar 26, 2019 at 14:01

Use the file /etc/ssmtp/revaliases to enter your aliases, e.g.

michel:[email protected]:smtp.gmail.com:465
  • that doesn't seem to work. When i send mail to michel it does not work.
    – Michel
    Commented Mar 26, 2013 at 8:39
  • What does "doesn't work" mean? What do the logs say?
    – Jenny D
    Commented Mar 26, 2013 at 8:40
  • I get the same error in my mail. What i described earlier (What ssmtp seems to do is to add the setting in the hostname to the local user name and use that as an email address.) still happens, the revaliases file isn't used. Isn't it btw strange that I have to specify a email server for an alias?
    – Michel
    Commented Mar 26, 2013 at 8:46

Try this:

Simplest way to send one-line mail out via command line using gmail?


[email protected]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .