Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a couple of cron jobs that somethime produce error output and would like to get a notification in my "real" email account, since I don't use my user's mailbox in my Ubuntu laptop, but cron (or is it postfix maybe) keeps trying to email the local root account.

I know I can add the MAILTO variable to the crontab:

ricardo@ricardo-laptop:~$ sudo crontab -l
MAILTO=redacted@gmail.com
# m h  dom mon dow   command
*/5 * * * * /home/ricardo/mrtg/cfg/run.sh

But it doesn't seem to pay any attention to it

I also tried adding my email to the /etc/aliases file and running newaliases

ricardo@ricardo-laptop:~$ cat /etc/aliases
# See man 5 aliases for format
postmaster:    root
root:          redacted@gmail.com
ricardo:       redacted@gmail.com

still, whenever cron wants to send an email it's still sending to root@my.domain.com:

ricardo@ricardo-laptop:/var/log$ tail mail.log
Aug  3 16:25:01 ricardo-laptop postfix/pickup[2002]: D985B310: uid=0 from=<root>
Aug  3 16:25:01 ricardo-laptop postfix/cleanup[4117]: D985B310: message-id=<20100803192501.D985B310@ricardo-laptop>
Aug  3 16:25:01 ricardo-laptop postfix/qmgr[2003]: D985B310: from=<root@144-68-247-190.fibertel.com.ar>, size=762, nrcpt=1 (queue active)
Aug  3 16:25:03 ricardo-laptop postfix/smtp[4120]: D985B310: to=<root@144-68-247-190.fibertel.com.ar>, orig_to=<root>, relay=smtp.gmail.com[74.125.157.109]:25, delay=1.5, delays=0.38/0.02/0.9/0.18, dsn=5.7.0, status=bounced (host smtp.gmail.com[74.125.157.109] said: 530 5.7.0 Must issue a STARTTLS command first. d1sm12275173anc.19 (in reply to MAIL FROM command))

Any suggestions? I'm running Ubuntu 10.04, with everything up-to-date


Solution

(thanks to Ressu)

The problem was with the file /etc/mailname

This file was set by the Ubuntu installer and had the wrong server-name. Once I changed it to match "ricardo-laptop" postfix realized the emails were intended for local delivery and started to follow the aliases

share|improve this question
up vote 17 down vote accepted

It would appear that you have configured smtp.gmail.com as your smarthost for the mail server. You need to remove the smarthost configuration or edit it so that your server is at all capable of sending mail to the outside world.

The configuration you have now for the mail forward appears to be working, but is failing because smtp.gmail.com is rejecting the mail.

Update: For future reference, the problem was in /etc/mailname which listed a name that wasn't in the mydestinations list of postfix. This caused all mails to be considered foreign and the mail bypassed /etc/aliases processing.

share|improve this answer
    
I'm ignoring the TLS error for now, and concentrating in the fact that the last line in mail.log says: postfix/smtp[4120]: D985B310: to=<root@144-68-247-190.fibertel.com.ar> so cron is still trying to email my root account instead of my gmail account I was afraid that leaving gmail's response in the question would be confusing,but I didn't want to change it too much so I don't loose valuable information. I'll try to fix the TLS error now, but I'm confident it should have nothing to do with the wrong destination problem – Ricardo Reyes Aug 3 '10 at 20:21
    
Could you include your main.cf for postfix. I suspect that your postfix instance thinks that the mail is not local to begin with, only local mail get affected by aliases file – Ressu Aug 3 '10 at 20:32
    
Here is my postfix.cfg: cl1p.net/postfix I tried removing the smarthost option, but it only changed Gmail's error message, since my ip doesn't resolve correctly. Keep in mind that this is isn't a server, it's just my personal laptop and the only emails I need to deliver are the cron alerts, to my own gmail account. Thanks. – Ricardo Reyes Aug 3 '10 at 20:41
1  
Hmm.. does your /etc/mailname have your hostname in it? for some reason postfix appears to think that it is called 144-68-247-190.fibertel.com.ar instead of ricardo-laptop. Also, what does the hostname command say? – Ressu Aug 3 '10 at 21:41
    
Postfix needs to be configured as a full mail server, not as a satellite to gmail. Otherwise, there will be authentication problem because the sender is not a user for gmail. – txwikinger Aug 3 '10 at 21:44

thought I'd add on for people who discover this as I did. An easy alternative if you want all your mail from your root account is to run this command:

sudo nano ~/.forward

You can then put in a single email or separate more than one with commas. This will forward all of your root emails (assuming you're using the root) to the email address(es) in this file.

Once you've added the emails, Press Ctrl+X then Y to save the changes.

share|improve this answer
    
this puts a file in my user's home though, not root's? – endolith Feb 10 at 5:43

protected by Byte Commander Mar 14 at 14:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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