apache sendmail: trying to change user "from" address from apache to domain account

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.

The goal

All I want to do is change the envelope "from" address for all email sent from [email protected] to [email protected], always.


What I've already done

I am running Apache, PHP, and sendmail on CentOS 5.5, [email protected]. 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:

define(`SMART_HOST', `192.168.0.4')dnl

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 protected]

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:

  • mailertable
  • virtusertable
  • FEATURE(`accept_unresolvable_domains')dnl
  • LOCAL_DOMAIN(`localhost.localdomain')dnl
  • FEATURE(`genericstable')dnl
  • /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 [email protected] [email protected]

I get this error in /var/log/maillog:

Mar 30 08:56:16 localhost sendmail[24022]: p2UCuE8w024022: [email protected], size=5, class=0, nrcpts=1, msgid=<[email protected]>, relay=user@localhost
Mar 30 08:56:19 localhost sendmail[24022]: p2UCuE8w024022: [email protected], [email protected] (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[24022]: p2UCuE8w024022: p2UCuE8x024022: DSN: User unknown
Mar 30 08:56:23 localhost sendmail[24022]: p2UCuE8x024022: [email protected], 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.


Help

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?


I've figured out using the -f parameter. I started modifying sendmail.mc from scratch, I only included the MASQUERADE_AS properties.

Turns out it was a rejection by our network's firewall. I added an exception in the firewall. Sigh...

EDIT: I've resolved this using POSTFIX. Forget sendmail...