# Cron Output Email to Root User



## RHITMacMan (Jun 27, 2002)

Now that I have Postfix installed and sendmail now works, my system now is able to send the e-mail it has always wanted to send.  Unfortunately, I don't want it to be sent for a couple reasons.  One, I'm not sure that I can retrieve mail sent to the root user.  Two, the mail has been being sent to the main computer on my domain's root account and the not local computer's root account.  I know this is a problem with the way I setup the domain, I should be able to fix this.  Although, I was told by one of the network Administrators, that I could fix the problem by setting a mailto environment variable for the crontab to send mail to root@localhost and not to root@mydomain.  Then I would still be able to specify my domain as the domain for the whole network without any problems for the meantime.  

In addition to the cron jobs sending output e-mails to the root user, "daily run output" logs are being sent to the root user as well.  I would like to make sure that none of these e-mail status' leave my computer.  Like suggested by my network admins, I would like have them sent to the root@localhost and not root@mydomain.  How can I make sure that any mail intended for the root account on my local system be sent to root@localhost and not root@mydomain???


----------



## hazmat (Jun 27, 2002)

If you look in NetInfo under /aliases, you will see where root's mail is going.  I think by default it goes to /dev/null.  Change it to whatever you want.


----------



## RHITMacMan (Jun 28, 2002)

My .forward file does contain "/dev/null/" for the address location.  So this causes it to be sent to root@mydomain by default?  I believe I am going to try adding the address root@localhost to the .forward file for root.  If I do this, how can I retrieve the root mail?  I think this has been covered before, not sure though.  If so, if you could, point me in the direction of the thread if you remember it.  I think I can use "sudo mail" to see if root has mail, right?


----------



## hazmat (Jun 28, 2002)

testuser: Interesting about the lack of alias for root in NetInfo.  AFAIK, I never manually added that.  And more interestingly, /var/root/.forward is dated June 20, probably about the time I installed Postfix and changed the alias in NetInfo for root from /dev/null to my local account, which leads me to believe that NetInfo actually creates/updates a ~/.forward for aliases of system accounts.  Does this make sense?  I don't think I ever did anything with a /var/root/.forward manually either.

RHITMacMan: It's all what you're comfortable with.  I personally use mutt for all my email, which is a text-based mailer, so I use it right from the Terminal.  That works for me for local mail.  You have a few options I suppose.

1. Use a text-based mailer of your choice from the Terminal.  Mutt, Pine, Elm, mail, mailx, etc.

2. Put a real email address in root's .forward so all root mail goes to some account you have that you can get with your GUI POP/IMAP mailer of choice.

3. Set up POP or IMAP locally and use your GUI mailer of choice to get them that way.

Hope this helps....


----------



## RHITMacMan (Jun 28, 2002)

I changed the .forward file to an actual e-mail address instead of /dev/null.  As suspected, this did not change anything.  None of my e-mail is forwarded to this address.  As far as NetInfo aliases, I'm not sure where I would put an e-mail for the root account.  When I open NetInfo, and click on "aliases" and then "root" I see the property "name" with the value of "root" and the property "members" with the value of "username@localhost" where username is one of my Admin login accounts.  So I don't know if I would add an "address" property with value of "name@somedomain.com" or what.  If you remember, I was getting mail sent to the root user of my main domain, not the local root user even when the .forward file was set to /dev/null.  Which according to testuser, would send the mail for the root user in a big black hole.  

So one of two things is wrong.  One, an alias in NetInfo needs a property added or modified.  Or two, Postfix is actually sending mail to the root user on it own accord without referencing either NetInfo or the .forward file and therefore something in the Postfix config files needs changed.  One thing interesting to note, the "name" property in NetInfo under aliases for root does not have @localhost appended to its name, but the members property does.  I'm not sure if this is a problem or not.  Also, I've only started getting mail delivered to the local root account only after I changed the $mydomain variable in the Postfix main.cf file to "localhost" from the address of my whole domain.  So it seems like Postfix could likely be the problem.

I've been getting the mail for the root account with the terminal "mail" app.  I'd like to get a GUI app to get the mail locally or remotely, but I may have to wait until I have completed Phase II of my mail server installation.

*Mail Server Installation Project:*
Phase I:   Setting up Postfix with SMTP capabilities
Phase II:  Setting up an IMAP client, and maybe a POP client
Phase III: Writting a webmail interface for retrieving mail over the web for all local mail accounts


----------



## RHITMacMan (Jun 30, 2002)

I changed the NetInfo alias like suggested.  This did not help at all.  Mail is still being sent to root@localhost for the time being.  Which I'm sure represents root@$mydomain from my Postfix installation.  This is the only way I figure it is doing this.  Neither the NetInfo alias or the .forward file effect where mail for the root user is sent.  It seems like it must be something with Postfix, I'm just not sure what it is, or what I need to change.  I noticed there is a file called "aliases" in the /etc/postfix/ directory.  Could there be a setting in there that is causing the problem?  I noticed the following couple of lines which looked curious, but they were both commented out.

# Person who should get root's mail
#root:          you

There are also several other root settings listed that aren't commented out.  I'm just not sure.  But it seems something very peculiar is going on..


----------



## hazmat (Jun 30, 2002)

> _Originally posted by testuser _
> *You probably need to restart lookupd daemon after making the changes to NetInfo aliases:
> sudo kill -HUP `cat /var/run/lookupd.pid`
> 
> I will try to update the instructions in my last post. *



No, changing NetInfo aliases takes effect right away.


----------



## hazmat (Jun 30, 2002)

> _Originally posted by testuser _
> *That is what I experience also.  But can you think of any other reasons why RhitMacMan cannot update his root alias either in the .forward, or in NetInfo? *



Huh.  A thought of one thing to look at is in /etc/postfix/main.cf.  What is your alias_maps setting?  Mine is netinfo:/aliases.  If it is, then in NetInfo Manager, what do the settings for /aliases/root look like?  Mine has two properties, 'name' and 'members'.  Name is 'root' and members is 'hazmat', the local user I have root mail sent to.  You can also put in an email address.


----------



## RHITMacMan (Jun 30, 2002)

I looked into the problem further and have noticed the mail is now neither being directed to the external mail account I setup in NetInfo (and the .forward file) or the root account.  I thought it was still being sent to the root account since I had so much mail to sort through from cron jobs, but it quit I believe after I changed the alias in NetInfo.  But, it's not being sent to the address I setup.  So something is still wrong, it's going either nowhere or somewhere it's not supposed to go.  Is there a place I check to see where this mail is going now?

Sorry for the misinformation.  Since the mail wasn't going to the address I specified and there was still a lot of root mail, I jumped to the wrong conclusion that it was still going to root.  As stated above though, I don't know where it's going now.  I'll try a few more things and see if I can get things to work.  Maybe I'll try specifying various addresses and seeing the effects.

*UPDATE:*  I tried a couple different addresses and it looks like the original address I specified was bouncing the mail or filtering it as junk mail.  That's the reason I was confused as to where the stuff was going.  Things are working properly then.  Now I just need to get IMAP going.


----------



## hazmat (Jun 30, 2002)

On my system, Postfix seems to log to /var/log/mail.log.

And what about my questions above?


----------



## RHITMacMan (Jul 1, 2002)

I checked and my alias map setting is "alias_maps = netinfo:/aliases" like expected.  So it was actually using NetInfo, like has finally been been discovered after much laboring.

I have actually already answered your other question...



> _Originally posted by RHITMacMan, 06-28-2002 10:16 PM_
> *When I open NetInfo, and click on "aliases" and then "root" I see the property "name" with the value of "root" and the property "members" with the value of "username@localhost" where username is one of my Admin login accounts.
> *



This was before I changed the $mydomain variable in Postfix to localhost and not mywholedomain.com.  Otherwise, my mail was getting sent to root@mywholedomain.com and not re-directed since it was going to the root account at mywholedomain.com, and not to my local root account and then redirected.


----------

