Adding aliases to Postfix on Ubuntu

Today I've been fiddling with Postfix a bit. PHP applications always want to send email, and it's a bit of a pain getting Postfix to properly relay email.

This blog post is just a quick one about how to add new aliases to Postfix. I'm running Postfix on Ubuntu, so the location of the config. files I mention may be different if you're using a different distribution. What I wanted to do was add another alias to Postfix, so that all email for the nobody user goes to my account, ell. This is what I did:

  1. Edited /etc/aliases and added a line (notice root is already aliased to my personal account):
    root:   ell
    nobody: ell
    
  2. As root, run the newaliases command. This is the bit which isn't obvious: it regenerates your alias database file.
  3. Reload postfix: /etc/init.d/postfix reload
  4. Test by sending an email to nobody@localhost

Short but sweet.

Comments

reload is not needed

reload is not needed

Specifying "From" address in Postfix

Hi Elliot,
I'm having an issue on my server, which is running Postfix. The issue is that, even when my php script explicitly specifies a "From" address in the mail() function, when i tail the /var/spool/maillog file, I see that the email is being sent as "nobody@servername.com" (where "servername" is the hostname of the box)

Is there anything i can do to force Postfix to use the "From" address that's specified in the script, instead of defaulting to "nobody" ?

Thanks in advance.

Mail

The issue you are seeing is NOT because of postfix. In your php code, you can change the FROM address specifically to whatever you want. Take a look at the mail function on the PHP website and make sure you are doing it correct:
http://php.net/manual/en/function.mail.php