Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need a way to configure sendmail to set the envelope sender of every message to a fixed value (say 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

(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)


share|improve this question
up vote 2 down vote accepted

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

R$+ <>   $: john.doe <>

It adds extra rewriting at the end of rule set handling envelope sender address of all smtp based mailers. The R line rewrites all * addresses into

You may test it using the script below:

/usr/sbin/sendmail -bt <<END
/tryflags es
/try esmtp
share|improve this answer
Xactly what I was looking for. Thx. – Alien Life Form Mar 10 '14 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 '14 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:)).


Do not forget to specify domains undergoing such rewriting in


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

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 '14 at 8:58

Your Answer


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.