5

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.

Alien Life Form
  • 2,309
  • 2
  • 21
  • 32

2 Answers2

3

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
AnFi
  • 6,103
  • 1
  • 14
  • 27
  • 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 :-) – AnFi Mar 10 '14 at 14:57
2

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

AnFi
  • 6,103
  • 1
  • 14
  • 27
  • 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 08:58