Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 apache@localhost.localdomain to, always.

What I've already done

I am running Apache, PHP, and sendmail on CentOS 5.5, linux@localhost.localdomain. We have an SMTP server at The domain's email accounts are all at

I have successfully set up "smart host" using this line in the file:

define(`SMART_HOST', `')dnl

Then I set up masquerading, and was hopeful this would solve it. I have this in the .mc file:


This rewrites "to" addresses, but not "from" addresses. Testing from the command line:

sendmail -v

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

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

Mar 30 08:56:16 localhost sendmail[24022]: p2UCuE8w024022:, size=5, class=0, nrcpts=1, msgid=<201103301256.p2UCuE8w024022@localhost.localdomain>, relay=user@localhost
Mar 30 08:56:19 localhost sendmail[24022]: p2UCuE8w024022:, (500/502), delay=00:00:05, xdelay=00:00:03, mailer=relay, pri=30005, relay=[] [], 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:, delay=00:00:04, xdelay=00:00:04, mailer=relay, pri=31029, relay=[] [], 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 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?

share|improve this question

migrated from Mar 31 '11 at 12:53

This question came from our site for professional and enthusiast programmers.

Is there a web mailbox on that server? Even if it's just an alias, you should make sure it exists – Marc B Mar 30 '11 at 14:53

1 Answer 1

I've figured out using the -f parameter. I started modifying 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...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.