System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Sendmail : modify outgoing email address domain name

 
Shalabhgoyals
Occasional Contributor

Sendmail : modify outgoing email address 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 name@abc.com, is automatically changed to name@xyz.com by sendmail before sending the mail out ?

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

Thanks.
8 REPLIES
Sunny123_1
Esteemed Contributor

Re: Sendmail : modify outgoing email address domain name

Hi

Look out for DS in /etc/sendmail.cf file and make an entry there of your domain i.e xyz.com

Regards
Sunny
Sunny123_1
Esteemed Contributor

Re: Sendmail : modify outgoing email address domain name

Hi

the configuration file is /etc/mail/sendmail.cf

Regards
Sunny
Mel Burslan
Honored Contributor

Re: Sendmail : modify outgoing email address domain name

I loved the responses totally unrelated to what you want to do, above this one.

-You need to edit /etc/mail/sendmail.cf file
-find the line starting with letters DM, most probably followed by nothing
-Change this line to
DMmydomain.com

also make sure you do not have any lines starting with

Dj$w.mydomain.com

if there is, try commenting it out.

Give it a try and see. sendmail is a big behemoth, which is very hard to configure without seeing the whole sendmail.cf file and making a couple of tests before being able to say, it will do what you want to.

Hope this helps
________________________________
UNIX because I majored in cryptology...
Pete Randall
Outstanding Contributor

Re: Sendmail : modify outgoing email address domain name

More like "Partly Cloudy", Mel?

;^)


Pete

Pete
Mel Burslan
Honored Contributor

Re: Sendmail : modify outgoing email address domain name

@Pete: Looking out my office window, I see the fog coming down on LAX . Must be getting to me too :)
________________________________
UNIX because I majored in cryptology...
jerry1
Super Advisor

Re: Sendmail : modify outgoing email address domain name

Yes, there is a way to transpose addresses
to whatever you want. And it may depend on
the version of sendmail binary and
sendmail.cf you are running. It's not easy
for some to setup.

This is the way I do it.
I use a virtusertable. If your sendmail.cf
file does not have something like this
entry, then you need to upgrade sendmail.
Mine is old I'm sure. But it still works.

##### @(#)virtusertable.m4 8.8 (Berkeley) 10/6/1998 #####

# Virtual user table (maps incoming users)
Kvirtuser dbm -o /etc/mail/virtusertable


I added the line in sendmail.cf:

C{Virt}


On this line I put the domains I want to
transpose.

C{Virt}domain1.com domain2.com


Then I changed line in sendmail.cf for $=w
to $=(Virt):

# handle virtual users
#R$+ < @ $=w . > $: < $(virtuser $1 @ $2 $@ $1 $: @ $) > $1 < @ $2 . >
R$+ < @ $={Virt} . > $: < $(virtuser $1 @ $2 $@ $1 $: @ $) > $1 < @ $2 . >


I then have a virtusertable dbm file that
I can build with an alias makevirt:

makevirt='vi /etc/mail/virtusertable;makemap dbm /etc/mail/virtusertable

The virtusertable has entries like:

John.Doe@somedomain John.Doe@otherdomain
Jane.Doe@somedomain Jane.Doe@domain1.com

"otherdomain" can be routed to another
gateway with sendmail dbm file:

/etc/mail/mailertable


With entries like:

otherdomain smtp:relay.domain.com
domain1 smtp:relay1.domain.com
domain2 smtp:relay2.domain.com


I have an alias for this also to build the
dbm file:

makemailer='vi /etc/mail/mailertable;makemap dbm /etc/mail/mailertable < /etc/mail/mailertable'


And it is incorporated in sendmail.cf also:

##### @(#)mailertable.m4 8.10 (Berkeley) 10/6/1998 #####

# Mailer table (overriding domains)
Kmailertable dbm -o /etc/mail/mailertable

R< $+ > $* $: < $(mailertable $1 $) > $2 lookup


The full user addresses are either expanded
from the sendmail aliases file from unix ids
or are generated from applications as the
full domain email addresses. Works pretty
good for me in handling email routing
to either our Exchange gateway or up to
some other corp smart email relay or to
another user. There should be some docs on
the sendmail.com web page about doing some
of this. I have not looked at it in years
though. The way I do it above is just the
way I ended up doing it back in the 90's.
I'm sure things have changed since then.


Shalabhgoyals
Occasional Contributor

Re: Sendmail : modify outgoing email address domain name

Thank you for the replies.
Tried various changes, but couldn't accomplish my requirement.
Is the Virtusertable only for mapping incoming mail ?
Should I instead be using genericstable ?

I want that any outgoing mail sent by a shell script using sendmail to john@abc.com is changedby sendmail to john@xyz.com before sending the mail to the SMTP server.

Please assist.
Shalabhgoyals
Occasional Contributor

Re: Sendmail : modify outgoing email address domain name

Repoening as a different thread since the Subject of this thread is incorrectly mentioned, and hence causing confusion with the solutiions.