I apologize if I am asking a question already answered, but my problem isn't really that I haven't found an answer. I have, in fact, found a half-dozen different "solutions" to my problem, tried them all, in various combinations, and have been consistently unsuccessful.
All I want to do is change the envelope "from" address for all email sent from firstname.lastname@example.org to email@example.com, always.
What I've already done
I am running Apache, PHP, and sendmail on CentOS 5.5, firstname.lastname@example.org. We have an SMTP server at 192.168.0.4. The domain's email accounts are all at @domain.org.
I have successfully set up "smart host" using this line in the sendmail.mc file:
Then I set up masquerading, and was hopeful this would solve it. I have this in the .mc file:
FEATURE(`masquerade_entire_domain')dnl FEATURE(`masquerade_envelope')dnl FEATURE(`allmasquerade')dnl MASQUERADE_AS(`domain.org')dnl MASQUERADE_DOMAIN(`domain.org.')dnl MASQUERADE_DOMAIN(`localhost.localdomain.')dnl
This rewrites "to" addresses, but not "from" addresses. Testing from the command line:
sendmail -v email@example.com
Always is shown from the local user (in this case root, or my local user account).
I had read that "sendmail" command sometimes bypasses masquerading. Nevertheless, using the "mail" command has the same result.
After that, I have explored several "solutions", including:
- /etc/mail/access file
- /etc/mail/local-host-names file
- /etc/mail/trusted-users file
All to no affect.
The last thing I've tried
So, I decided to go in a different direction, and try to set the envelope "from" address via PHP, using either the configuration in /etc/php.ini, or adding the -f parameter to the mail() function or to sendmail command.
If I run this command:
sendmail -v -f firstname.lastname@example.org email@example.com
I get this error in /var/log/maillog:
Mar 30 08:56:16 localhost sendmail: p2UCuE8w024022: firstname.lastname@example.org, size=5, class=0, nrcpts=1, msgid=<201103301256.p2UCuE8w024022@localhost.localdomain>, relay=user@localhost Mar 30 08:56:19 localhost sendmail: p2UCuE8w024022: email@example.com, firstname.lastname@example.org (500/502), delay=00:00:05, xdelay=00:00:03, mailer=relay, pri=30005, relay=[192.168.0.4] [192.168.0.4], dsn=5.1.1, stat=User unknown Mar 30 08:56:19 localhost sendmail: p2UCuE8w024022: p2UCuE8x024022: DSN: User unknown Mar 30 08:56:23 localhost sendmail: p2UCuE8x024022: email@example.com, delay=00:00:04, xdelay=00:00:04, mailer=relay, pri=31029, relay=[192.168.0.4] [192.168.0.4], dsn=2.0.0, stat=Sent (Ok: queued as B5E2E40E0A2)
Which is basically a "User unknown" 550 error.
Please help. What do I need to change? Should I just start over in the sendmail.mc file? It has a ton of config options stuffed in it, over days of trying things. Why is changing the envelope "from" address via the command line generating a "User unknown" error?