20

I have a server running python, php, perl, ruby, and I have couple applications which also send mail. I was wondering in case if one of the applications don't specify a from email address, the sender email address is set to http@example.com and the sender name was "http".

I was able change the sender name by going into /etc/passwd and changing the name to what I wanted, but how do I change http@example.com to admin@example.com?

samwell
  • 2,567
  • 7
  • 30
  • 47
  • 1
    You would probably get a better response if you ask this on http://superuser.com/ which is one of StackOverflow's many sister sites - and more tailored to your question. – Taryn East May 05 '13 at 00:49

1 Answers1

40

You can use the smtp_generic_maps of postfix to rewrite email headers for outgoing smtp mail:

user:~$ echo "http@example.com  admin@example.com" >> /etc/postfix/generic 
user:~$ echo "smtp_generic_maps = hash:/etc/postfix/generic" >> /etc/postfix/main.cf
user:~$ postmap /etc/postfix/generic
user:~$ service postfix restart
Thomas8
  • 1,035
  • 1
  • 11
  • 20
knittl
  • 197,664
  • 43
  • 269
  • 318
  • 11
    echo "http@example.com admin@example.com" >> /etc/postfix/generic might be easier for many to read. – G. Allen Morris III Jan 19 '13 at 00:49
  • 2
    @knittl What about also overriding sender name? It works but send email as "fromme@example.com(root)". Almost there, but not quite – katit Apr 29 '15 at 04:35
  • 1
    "postmap: warning: /etc/postfix/generic, line 1: expected format: key whitespace value" – Tom Feb 01 '16 at 04:09
  • 2
    You can also skip the command `postmap /etc/postfix/generic` and tell main.cf that you use a `texthash` instead of a `hash`: `echo "smtp_generic_maps = texthash:/etc/postfix/generic" >> /etc/postfix/main.cf` – Daan Jul 05 '16 at 14:07