Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need a way to configure sendmail to set the envelope sender of every message to a fixed value (say foo@bar.com). Note that this is not answered by any of the MASQUERADE features/macros (that I know of): I want to also override the envelope user and set it to a fixed value.

EDIT: Also, I do not want to masquerade the header sender. So GENERICSTABLE + MASQUERADE_ENVELOPE does not cut it, either. What I need is the equivalent of command line sendmail -f foo@bar.com

(Rationale: I am forced - by the customer - to go through an authenticating relay which insists on having a given envelope sender address - and no, I am not trying to circumvent any antispam measure, I merely want to send root's mail - and other administrative stuff - offsite. It is an application server, and all the mail is originated by servers, but sender addresses need to be meaningful nevertheless)

TIA.

share|improve this question

2 Answers 2

up vote 1 down vote accepted
+50

It may be achieved using ugly but very simple hack. Put it after MAILER(smtp) in your sendmail.mc file and generate new sendmail.cf file.
There MUST BE a tab (\t) before $: in R line.
divert(0) cancels effects of MAILER_DEFINITIONS.

MAILER_DEFINITIONS
SEnvFromSMTP
R$+ <@foo.org.>   $: john.doe <@example.net.>
divert(0)

It adds extra rewriting at the end of rule set handling envelope sender address of all smtp based mailers. The R line rewrites all *@foo.org addresses into john.doe@example.net

You may test it using the script below:

/usr/sbin/sendmail -bt <<END
/tryflags es
/try esmtp xyz@foo.org
END
share|improve this answer
    
Xactly what I was looking for. Thx. –  Alien Life Form Mar 10 at 13:38
    
It is a simple, easy to maintain but uncomfortably hackish mc fix. The right way from cf perspective would be longer and harder to maintain on long run. Welcome to the world without perfect choices :-) –  Andrzej A. Filip Mar 10 at 14:57

You may use FEATURE(genericstable) and FEATURE(masquerade_envelope) to rewrite all sender addresses in your host email domain (envelope sender and header sender (From:)).

generictable

@foo.org  jane.doe@example.net

Do not forget to specify domains undergoing such rewriting in sendmail.mc:

GENERICS_DOMAIN(`foo.org')

You may use FEATURE(local_no_masquerade) to exclude local email from such rewrites.

http://www.sendmail.com/sm/open_source/docs/m4/masquerading_relaying.html

share|improve this answer
    
This is interesting, but I want the header sender to remain untouched. Editing the question to reflect this. I suspect that a LOCAL_RULE (something) is called for to nail this, but that's above my capacity to write. –  Alien Life Form Feb 28 at 8:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.