Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

michel@mypi

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.
root=MYNAME@gmail.com

# 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=smtp.gmail.com:465

# Where will the mail seem to come from?
#rewriteDomain=gmail.com

# The full hostname
hostname=MyPi

# 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 
AuthUser=MYNAME
AuthPass=MYPASS
FromLineOverride=YES
UseTLS=YES
share|improve this question
    
How does gmail fit into this description? –  tink Mar 25 '13 at 20:08
    
ehm, i'm using the gmail account to send email with ssmtp –  Michel Mar 25 '13 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 Mar 25 '13 at 21:20
1  
@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 Mar 25 '13 at 21:38
    
@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 Mar 25 '13 at 21:45
show 4 more comments

2 Answers

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<yourname@youremail.com>

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

share|improve this answer
    
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 Apr 14 at 14:02
add comment

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

michel:username@gmail.com:smtp.gmail.com:465
share|improve this answer
    
that doesn't seem to work. When i send mail to michel it does not work. –  Michel Mar 26 '13 at 8:39
    
What does "doesn't work" mean? What do the logs say? –  Jenny D Mar 26 '13 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 Mar 26 '13 at 8:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.