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.

As a newbie Postfix user, I've gotten so far and now I am stuck with a SMALL problem.

I would like to configure my local network servers to send alerts and like using the following:

1) From address: hostname@domain.com

2) From name: Hostname

I can get #1 to work fine using smtp_generic_maps

The problem is that on my email client, the name is listed as "root" - as in the header shows the following:

Date: Sun, 29 Jul 2012 13:21:01 -0400 (EDT)

From: zeus@domain.com (root)

To: undisclosed-recipients:;

I'd like to change it to "From: zeus@domain.com (Zeus)"

I imagine that this can be done in the headers_check, but so far I haven't gotten anything to work and before I waste a ton of time trying to get this to work, I'd like to make sure I am on the right track.

My aliasing and genericmaps are set up correctly (As far as I can see and know - the results are correct!). I just want to change that last bit in the From field to reflect the hostname.

I would also like to add something in the subject of the outgoing messages for easy filtering - something like Subject: [Zeus.domain] - "Original Subject"

Any suggestions are much appreciated. Thanks!

share|improve this question
add comment

2 Answers

This is not a job for the MTA; it should be done by the mail client.

Postfix is merely reporting the From: header as passed along by the client; in this case, porbably cron thorugh sendmail(1), which sets the friendlyname to the original sender (system user "root")

Why not have each servers' processes send mail to a designated local system account, and then process that and forward it to wherever you want ?

This allows you to modify each machine's outgoing email while avoiding the (unnecessary) mangling of a central MTA.

share|improve this answer
    
Okay - based on your suggestion I changed the friendly name to something more along the lines of what I wanted. If there was a case which I could not do this and had control, what could I do to "force" this change in the MTA? –  JTWOOD Aug 1 '12 at 10:54
    
ITYM "had NO control over the clients", because it doesn't make sense otherwise. In that case, you would have to use header_checks. –  adaptr Aug 2 '12 at 8:14
    
I don't have any control over the one daemon sending emails - it seems to be hardcoded to send to the box administrator, which in this case is root. By changing the friendly name of root to "SERVERNAME" I at least don't have every box with this daemon sending me email from 'root' - instead it shows up as 'SERVERNAME'. -- The minus is that I never actually got header checks to work. The regex I used functioned fine using other tools on command line, but nothing ever replaced. I accept your solution because I absolutely agree - mucking about with header_checks is a major PITA for this case. –  JTWOOD Aug 6 '12 at 14:48
add comment
  1. Change e-mail address:

    • vi /etc/postfix/generic

      root     myname@domain.tld
      
    • vi /etc/postfix/main.cf

      smtp_generic_maps = hash:/etc/postfix/generic
      
    • postmap /etc/postfix/generic

    • postfix reload
  2. Change name - change name in passwd file from root to My Name:

    • vi /etc/passwd:

      root:x:0:0:Own Name:/root:/bin/bash
      
share|improve this answer
add comment

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.