UPDATE: I solved this by setting myorigin to $myhostname ("prime.example.com"). Now system mail goes to "email@example.com", which is what I wanted. My app explicitly says it wants to send from "firstname.lastname@example.org", and that works too. I'm not entirely sure this is the proper way of doing things, so I remain open to further suggestions.
I want locally generated mail currently sent via smtp to instead be delivered locally. Right now they go to user@domain instead of user@hostname. I'm using Postfix 2.11 on Ubuntu Server 14.04.
127.0.1.1 prime.example.com prime 127.0.0.1 localhost
myhostname = prime.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname ("example.com") mydestination = prime.example.com, localhost.example.com localhost mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = 127.0.0.1 inet_protocols = all
MX records for example.com point elsewhere; the server is used to send e-mail, not receive.
I can send email locally (showing from: email@example.com) from the command line by:
echo "This is the body of the email" | mail -s "This is the subject line" root
I can also send email via smtp for the domain (showing from: firstname.lastname@example.org) from cli by:
echo "This is the body of the email" | mail -s "This is the subject line" -a "From: email@example.com" <to-address>
However, when a simple cron job runs, mail is being sent via smtp to firstname.lastname@example.org, not locally to email@example.com as I want.
mydestination was supposed to prevent sending mail non-locally, so either I'm mistaken or I have a configuration problem somewhere. Any tips would be much appreciated.