Masquerade the from field using sendmail

Matthew Seaman m.seaman at plasm.demon.co.uk
Tue May 21 21:16:22 BST 2002


On Tue, May 21, 2002 at 03:15:27PM +0100, Mervyn Passmore wrote:
> I have a 4.5 BSD server that does our transactions, like invoices etc. I
> would like it to email our customers as the order status changes. I want =
the
> message to appear to come from our sales dept, but sendmail uses the
> server's login and server name. I can alter the 'Reply to', but not the
> 'From' by sendmail options.

If you've got sufficient flexibility in your server software, you can
feed e-mails directly into sendmail which gives you control over the
`From:' header ---

/usr/sbin/sendmail -t -oi -oem <<EOF
From: somebody at example.com
Subject: test message
To: whoever at example.org

Message text goes after a blank line.
EOF

This will alter the message header, but not the envelope sender ---
which usually appears in the delivered e-mail as the `From' (no colon)
line.  It's the envelope sender who will get any bounce-o-grams.  You
can only override the envelope sender ( -fuser at host.dom.ain on the
sendmail command line) if the sending user is listed under class `t'
--- Trusted users.  By default that's root, daemon or uucp, but you
can modify the list by adding something like this to your .mc file:

FEATURE(`use_ct_file')dnl
define(`confCT_FILE', `-o /etc/mail/trusted-users')dnl

which makes sendmail read in trusted users from the
/etc/mail/trusted-users file --- one user name per line.  That's the
default value for the file name btw, but using a `-o' flag as shown
will stop sendmail complaining if that file doesn't exist.
=20
> I read that masqerade_as can be set in my sendmail config file, and tried=
 to
> follow the instructions. My cf directory is empty, so cannot modify and m=
ake
> the .mc file.
>=20
> Does anyone know how to go about this? Which .mc file should I modify?  Or
> can I just modify the sendmail.cf file?

Others have commented on how to set up a custom .mc file. However
masquerading only lets you modify the RHS (host name part) of the
address.  If you want to modify the LHS (user name) of the address as
well, you need to use the genericstable stuff.  In your .mc file:

FEATURE(genericstable, `hash -o /etc/mail/genericstable')dnl
GENERICS_DOMAIN(`example.com')dnl

Then set up the genericstable file which just maps usernames to e-mail
addresses, eg.

teddy	Edward.Bear at example.com

Then just run `make' in /etc/mail to rebuild the hashed lookup table.

While the genericstable stuff works fine in combination with
masquerading, you can use it to override the RHS of the address as
well.

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
Tel: +44 1628 476614                                  Marlow
Fax: +44 0870 0522645                                 Bucks., SL7 1TH UK




More information about the Ukfreebsd mailing list