Removing apache@localhost from email headers?

Solution 1:

The from email address is the user of the daemon that called for the message to be sent (apache) @ the domain name configured in your MTA (either sendmail or postfix).

If your local MTA is postfix, you need to change the myorigin setting (which defaults to the configured hostname. localhost in this example). This setting is in the main.cf (default location in most distributions is /etc/postfix/main.cf). Just change that to the domain name you want it to send from. Then restart postfix.

Of course, it may be easier for you to just change the hostname of the server to match the desired sending domain.

Keep in mind, that if you are going to send email from this server for that domain, you will want to add a SPF DNS record allowing it, otherwise your messages will likely get dumped by spam filters.

Solution 2:

In looking over your config it seems there are a couple of bits missing (and sorry for my syntax, I don't post often):

You'll probably want to add the MASQUERADE_DOMAIN config option to go with MASQUERADE_AS, matching the MASQUERADE_DOMAIN to whatever the FQDN of the host is (hostname -f on most linux platforms). I've had it do strange things if they're not both there, so it would be:

MASQUERADE_AS(`mydomain.com')dnl
MASQUERADE_DOMAIN(`fqdnname.internal')dnl

and then this line:

dnl define(`confDOMAIN_NAME', `mydomain.com')dnl

Should really be

define(`confDOMAIN_NAME', `mydomain.com')dnl

or it will be ignored by the make/hash commands when you update the sendmail.cf file. This guy gives a great explanation of why What is the difference between "dnl" and "dnl #" in a sendmail.mc file?

I'm still trying to get rid of the "apache" part in my own server, but I hope this gets you a little closer!

Solution 3:

System -> Configuration -> Advanced -> System -> Set Return-Path -> Yes

or set it to email that you want to use. Just found this today - apparently some of the emails were getting rejected by mailservers with strict rules (.edu, .gov...etc)

Solution 4:

Add define(`confRECEIVED_HEADER', `internal info removed')dnl to submit.mc then generate .cf file and restart sendmail as usual.

Important: the file that should be edited in order for this to work is submit.mc, and NOT sendmail.mc. If you edit the sendmail.mc file instead, the Received header above the one you mentioned will be the one modified (that is Received: from mydomain.com (www.mydomain.com [127.0.0.1])).

Note: Instead of the literal string internal info removed you can reuse some of the info provided while hiding the sensitive one, for example: by $j id $i; $b to get by DOMAIN id ID; TIMESTAMP.

The above will remove/replace the information after the Received header you mentioned:

Received: (from apache@localhost) <----------- THIS IS WHAT I'M TRYING TO CHANGE
by mydomain.com (8.14.4/8.14.4/Submit) id fkdjfljlfsra39393;
Fri, 3 Apr 2015 15:35:01 GMT

See also similar question: How to remove Received: (from apache@localhost) and sendmail version from headers