Link to home
Start Free TrialLog in
Avatar of Mark
Mark

asked on

How to keep virtual domain name on outgoing sendmail

I have a host with multiple domain names: thishost.com, thathost.com. My sendmail.mc file has:

MASQUERADE_AS(`thishost.com')
FEATURE(`masquerade_envelope')
FEATURE(`masquerade_entire_domain')

I originally had this setting before adding thathost.com, mainly to prevent the hostname from showing up in the From:  address. e.g. myuser@thishost.com instead of myuser@server.thishost.com.  However, when I added thathost.com to /etc/mail/local-host-names and the line

thisuser@thathost.com          thisuser

to the /etc/virtusertable, I cannot send mail addressed from users on thathost.com. The domain always gets changed to thishost.com. E.g. a message sent by thatuser@thathost.com gets sent as From: thatuser@thishost.com.

I suspect the way to fix this is to remove the MASQUERADE_AS directives in sendmail.mc, but I'd like some confirmation from a expert before I start experimenting.
Avatar of xterm
xterm

How are you sending the mail?  You should be able to set the return-path with the -f flag to sendmail, and configure any From address you want.
Avatar of arnold
This only affects emails sent from the shell?  Look at configuring the email client settings to use a
Avatar of Mark

ASKER

xterm: > You should be able to set the return-path with the -f flag to sendmail, and configure any From address you want.

My email client is mailx 12.4. The option to do what you are describing is -r which sets the From address. That used to work just fine to set whatever address I wanted as the Reply-To:. Since setting /etc/virtusertable and /etc/local-host-names it will set the username part of the address, but always overrides what I specify as the domain. mailx also let's me specifically set From:, Reply-To: and Sender: The domains on all of these settings get overridden.

Arnold:  > Look at configuring the email client settings

Did that, and have had those set and working for years. With mailx you use the -A <account> parameter which looks up e.g.

account mercurey {
    set from="myuser@thathost.com (Mark Foley)"
    set hostname=thathost.com
    set ORGANIZATION="Mercurey Technologies SA, Limited"
}

in the $HOME/,mailrc file. Again, this has always worked until I set the virtusertable and local-host-names.

So, I don't think this is something I can fix from the mail client. I could remove the settings in virtusertable and/or local-host-names, but then this host won't be able to receive mail for thathost.com.

I could remove the MASQUERADE directive in sendmail.mc, but then I'll have the machine name attached to the domain name in the messages.

I'm sure I have some sendmail configuration wrong. Computers host email for multiple domains all the time. I've just never set this up before.

I'm in a quandary!
SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark

ASKER

I've tried two things, both of which appear to have worked:

1) I removed all MASQUERADE directives in sendmail.mc and put in $HOME/.mailrc e.g.

account thatDomain {
    set from="user@thathost.com (My Name)"
    set hostname=thathost.com
    set ORGANIZATION="Mercurey Technologies SA, Limited"
}

for each account I want to use. The "set from" seems to do the trick. I don't see that the "set hostname" does much.

2) I kept MASQUERADE_AS in sendmail.mc, removed FEATURE(`masquerade_envelope')
(not sure why I had that one set in the first place) and FEATURE(`masquerade_entire_domain'). I then added MASQUERADE_EXCEPTION(`thathost.com')

Both of these seem to work. Probably method 1 is more desirable because I'd have to set a MASQUERADE_EXCEPTION for each domain hosted.

I suppose if I multi-home a dozen different domains I'll have to have the appropriate "set from" in each user's .mailrc file.

Is this the normal way multi-homed hosts set up their email users? Seems highly dependent on the mail client used.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial