Changing default from e-mail address for system accounts when using sendmail

11

4

I would like certain system accounts (root and www-data) to have the header From: Example Company <noreply@example.com> when e-mail is sent using either the mail or sendmail commands, or from programming languages like PHP (which just uses a sendmail wrapper).

I would prefer not to have to add the -f and -F options every time I invoke one of these commands. Is there any way to configure this specifically for these accounts?

Operating system is Debian 7.2.

DanielGibbs

Posted 2013-12-31T05:31:25.137

Reputation: 447

2Are you sure you are using "Sendmail" as your MTA and not postfix or some other drop-in replacement with the name "sendmail" ? – davidgo – 2013-12-31T05:41:08.847

The MTA is postfix, but the sendmail executable is not symlinked to anything. – DanielGibbs – 2013-12-31T05:43:53.683

Answers

12

I ran into this recently.

You can change the address with the generic maps as davidgo mentioned.

In /etc/postfix/main.cf

Add this line

smtp_generic_maps = hash:/etc/postfix/generic

And then in /etc/postfix/generic
Add the line for the originating email address, and the email address you want it to appear to be from

root@system.fqdn noreply@company.com
www-data@system.fqdn noreply@company.com

and then run the following postmap command to re-generate the map:

 postmap /etc/postfix/generic

To make the user appear to be Example Company you need to set the GECOS field in /etc/passwd for root and www-data to be Example Company

Lawrence

Posted 2013-12-31T05:31:25.137

Reputation: 3 807

1

As you are actually using Postfix (The sendmail binary is actually Postfix), You can probably change the from adress this by adding a "smtp_generic_maps" file and mapping for the relevant addresses or using canonical_maps to do something similar. I don't think you will be able to change the associated account name (ie the part in the square brackets) without massive hoops but I could be wrong.

davidgo

Posted 2013-12-31T05:31:25.137

Reputation: 49 152

0

I write here what I made some times to find with Exim4

It's apparently simple :

  1. For the email rewrite:

    $ vim /etc/email-addresses
    
    root: noreply@example.com
    www-data: noreply@example.com
    
  2. For the fullname rewrite

    $ vim /etc/passwd
    
    root:x:0:0:Example Company:/root:/bin/bash
    www-data:x:33:33:Example Company:/var/www:/usr/bin/nologin
    

Olivier LONZI

Posted 2013-12-31T05:31:25.137

Reputation: 1