1832595 Members
3005 Online
110043 Solutions
New Discussion

Mail redirection

 
BAUKnight
Frequent Advisor

Mail redirection

I have a cron job that i use to run the oracle export and another one to back the exported files to a tape, my ron jobs run for user root, and an email is sent to the root user with the cron results.
OIn my environment i got Microsoft Exchange mail system, is there any way that i can redirect the mail, i mean instead of going to the system root mail files, i want it to go to my exchange mail.
and if it is possible, can i forward only the cron mail to go to my exchange.
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: Mail redirection

Shalom,

1) Set the exchange server to explicitly accept mail from the host running the cron job. It must permit relay and that should be set by IP address.
2) Modify /etc/mail/sendmail.cf Change DS to
DShostnameofexchangeserver

or

DS
[ip of exchange server]
example

DS
[192.168.0.10]
Where 192.168.0.10 is the IP address of the exchange server.

/sbin/init.d/sendmail stop
/sbin/init.d/sendmail start

Done.

check /var/adm/syslog/mail.log for diagnostics.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
yulianto piyut
Valued Contributor

Re: Mail redirection

Register tour server to mail server and edit /etc/mail/sendmail.cf
add your mail server that use to relay,, put in DS line.
ex:
DSsmtprelay.xxx.com


-yut-
Jonathan Fife
Honored Contributor

Re: Mail redirection

If you pipe the results to mailx in your crontab, it should send the results to the address you specify (assuming that sendmail and the relay are configured, as mentioned above). eg:

0 2 * * * su - oracle -c "/export/script.sh" 2>&1 | mailx -s "Oracle export results" you@youremail.com > /dev/null 2>&1

And just as a side note, if you wanted to redirect ALL of root's mail you could create a file called .forward in root's home dir, and put the email you'd like to forward everything to in the contents.

# echo you@youremail.com > ~/.forward
# at now
echo "testing email from $(hostname)"
^D
#
Decay is inherent in all compounded things. Strive on with diligence
Alan Buynak
Occasional Advisor

Re: Mail redirection

Hi Ahmed,

Besides the .forward file, you can also use /etc/mail/aliases. You can redirect emails for any of your Unix sign-ons all from this file. For example, if you wish to redirect root's mail, add the line:
root : joeadmin@yourdomain
Save the file, and then run sendmail -bi which will update the alias db.
BAUKnight
Frequent Advisor

Re: Mail redirection

thx customer cancled the issue.