Operating System - HP-UX
1825552 Members
2429 Online
109681 Solutions
New Discussion юеВ

Sendmail : Change outgoing email Recipient's domain name

 
Shalabhgoyals
Occasional Contributor

Sendmail : Change outgoing email Recipient's domain name

Our unix servers have numerous scripts configured in different directories to send out reports to exchange email addresses.
Our exhange server address is changing now(from @abc.com to @xyz.com) and not all of our above scripts use aliases. They use hardcoded email address within them( a not so good practise !)
Is there anyway to setup rules in sendmail so that any email sent from a script/shell or any mail client/pogram to @abc.com, is automatically changed to @xyz.com by sendmail before sending the mail out ? i.e if the shell script sends mail to johnsmith@hp.com, sendmail should actually send it to johnsmith@hewlettpackard.com ?
Please note we do not know all names to whom mails could be sent, so effectively sendmail should forward any mail sent to name@abc.com to name@xyz.com


Platform : HP-UX 11.11 on various HP 9000 and Itanium servers.

Thanks.
3 REPLIES 3
Mel Burslan
Honored Contributor

Re: Sendmail : Change outgoing email Recipient's domain name

I believe the answer to your question is NO. What you can do on the other hand is to replace the sendmail executable with a script and move the executable to some other name, say real_sendmail, you can build this intelligence into your script, replacing the sendmail.

a sample of how to do this is as follows. Please note that there is no error checking or any other consideration. It assumes you will use a simple command like 'sendmail email@domain.com' to send out emails. If you use any command line switches, you need to build this intelligence into your script as well.


mv /usr/sbin/sendmail /usr/sbin/real_sendmail


#!/usr/bin/ksh
#script name: /usr/sbin/sendmail
#
#this script replaces sendmail executable
#to capture and replace some a domain
#
RECEIVER=$1
name=`echo $RECEIVER | cut -d"@" -f1`
domain=`echo $RECEIVER | cut -d"@" -f2`
if [ "$domain" = "abc.com" ]
then
domain=xyz.com
fi
new_address="${name}@${domain}"
/usr/sbin/real_sendmail ${new_address}


Last but not the least, keep in mind that, any time you patch sendmail, it will overwrite your script. So, you have to remember to replace the executable with your script, after patching.
________________________________
UNIX because I majored in cryptology...
Steven E. Protter
Exalted Contributor

Re: Sendmail : Change outgoing email Recipient's domain name

Shalom,

There is a way to set up sendmail to do this.

http://www.sendmail.org
https://www.sendmail.org/tips/virtual-hosting.php

You need to set up virtusertables and genericstables to support the email addresses you want transmitted.

http://www.hpux.ws/buildmail.sendmail.text

That script shows the basics of building a sendmail configuration based on sendmail.mc or the HP-UX substitute.

If you run into specific issues, post back and I'll help you out.

I'll even help you do it if you want. http://www.isnamerica.com There is a contact form up there.

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
Dennis Handly
Acclaimed Contributor

Re: Sendmail : Change outgoing email Recipient's domain name