General
cancel
Showing results for 
Search instead for 
Did you mean: 

Changing a sender's address in sendmail

SOLVED
Go to solution
Luis Toro
Regular Advisor

Changing a sender's address in sendmail

We have internal HPUX servers that send emails to an exchange mail relay server. From there, emails are either routed locally or outside of our domain. The servers do not run sendmail as a daemon (ie., are not setup to receive email). I use the "masquerade" to change the domain to a valid external domain. Now I need to change the sender's address to a valid one. I've read up on the genericstable and it seems the solution lays there, but I don't want to create and maintain a "valid" sender email address for each userid on all the servers. Is there a method to map certain accounts which I know send external emails, and have all other userids map to a single generic, valid exchange email address ?
Thanks
9 REPLIES
Mel Burslan
Honored Contributor

Re: Changing a sender's address in sendmail

one crude way of doing this is to add a line like this to the beginning of your file that you are sending out, followed by an empty line

From: "Name Lastname"

my text starts at this line. The line above this is intentionally left blank.
blah
blah
...
and more blah

HTH
________________________________
UNIX because I majored in cryptology...
Kent Ostby
Honored Contributor

Re: Changing a sender's address in sendmail

I had a similar question several months ago and here was the thread with those answers:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=685447

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Luis Toro
Regular Advisor

Re: Changing a sender's address in sendmail

Thanks for the replies, but I would need to do this at the server level, not at the user or command level (as in using "mailx -r"). All of the outbound emails are automatically generated from scripts, or application utilities, and it would be a major endeavor to get the application folks to change their scripts/programs.
Geoff Wild
Honored Contributor

Re: Changing a sender's address in sendmail

Here's what we do for root:

add the following as the first line of rule 93 so e-mail from root appears to come from the UnixTeam mailbox
Rroot < @ $* > $* UnixTeam < @ $1 > $2 Special case for root

Watch out for tabs. Sendmail's rewrite rules are broken into fields by tab characters. Make sure the white space before UnixTeam is a tab, and put 2 tabs before Special.


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Luis Toro
Regular Advisor

Re: Changing a sender's address in sendmail

Geoff,
Can I put something like unixteam@domain.com in place of UnixTeam ? I've also been trying to configure the generics table and I can't get it to work. I've made the following changes to sendmail.cf:
- uncommented all lines for genericstable
- DMmydomain.com
- DSmailrelayhost.mydomain.com
- C{G}mydomain.com

in the genericstable file, I have the following:
myunixid myexchangeid@mydomain.com
myunixid@mydomain myexchangeid@mydomain.com
myunixid@servername.mydomain.com myexchangeid@mydomain.com

I then did the makemap dbm command to create the genericstable.db file.
Geoff Wild
Honored Contributor

Re: Changing a sender's address in sendmail

Might be possible - but if you are already masquerading (DM macro) then you don't need to.

At our site UnixTeam is a real Exchange user.

If someone was to reply to the email from that server - it would go to a "shared" mail box on the Exchange server that 9 of us admins have access to.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Christopher Caldwell
Honored Contributor
Solution

Re: Changing a sender's address in sendmail

I wouldn't fool much with the masquerade stuff; the genericstable will take care of "masquerading the domain" for you.

External well configured sendmail instances will check that the domain part of the from address is valid. You can also run checks against the relay.

Use the generics table to change the from address of a given Unix account to a _valid_ e-mail address where the domain part of the from address is valid - it doesn't matter if that host (MX) is different than where you are right now.


Uncomment the following lines in sendmail.cf.
Build the genericstable - filenames matter.
Restart sendmail.
Test.

#Kgenerics dbm /etc/mail/genericstable

#R< $+ > $+ < $* > @ $: < $(generics $1 $: $) > $2 < $3 >
#R< > $+ < @ $+ > $: < $(generics $1 $: $) > $1 < @ $2 >

If the testing doesn't work, give us some more debug:

1) Use the following debug commands to locate the problem:


1a) check if sendmail "sees" a genericstable entry:
echo "/map generics u...@mycomputer.myuniveristy.com"


1b) check processing of the addresses


sendmail -d60.1 -d21.12 -bt </tryflags hs
/try esmtp u...@domain.com
END


Replace u...@domain.com with address of "unmasqueraded" users.
-d60.1 - trace maps lookups
-d21.12 - trace sendmail.cf R lines processing
/tryflags hs - make /try check header sender
(*h*eader/*e*nvelope *s*ender/*r*ecipient)


Luis Toro
Regular Advisor

Re: Changing a sender's address in sendmail

Thanks for the details Chris.
I assigned this to another SA, and she got it to work by using the userdb table to basically map a UNIX account to a valid domain email address. What's the difference then between the genericstable and userdb ?
BTW: we are not running sendmail as a process (ie., it does not listen for incoming email).
Christopher Caldwell
Honored Contributor

Re: Changing a sender's address in sendmail

assigned this to another SA, and she got it to work by using the userdb table to basically map a UNIX account to a valid domain email address. What's the difference then between the genericstable and userdb ?
BTW: we are not running sendmail as a process (ie., it does not listen for incoming email).

The user database alllows sender and recipient addresses to be re-written under the control of an external database.

Names are looked up in the user database after aliasing but before forwarding.

The user database is a bit more complicated than the generics database, which is used to re-write just the sender's address.

Here's the usage information for generics out of the sendmail release notes:

genericstable- to do a more general rewriting of outgoing addresses. Defaults to ``hash -o /etc/genericstable''. Keys are user names; values are outgoing mail addresses. Yes, this does overlap with the user database, and figuring out just when to use which one may be tricky.

I'd guess that the thinking is if you're already using userdb to rewrite recipient addresses, why not use it to rewrite sender addresses. If you're not using anything, or if you just want to rewrite sender addresses, use the genericstable.