I've been grappling with this issue for almost a week now.
What is happening is the 'user' in this case 'apache' is sending the notification email for a new signup as 'apache@localhost' web server is lighttpd.
The local email instance running Sendmail, forwards this email without incident, however, a 'Received: (from apache@localhost)' appears in the header under the one placed by the Sendmail server. This has the effect of causing some of these signup emails to be classified as junk or are refused delivery (as per the maillog). I've seen numerous posts across the 'net detailing this problem, but no concrete solutions have been posted.
I've tried using the genericstable, but this ONLY works when a "Smart Host" (external relay MTA) is specified. I've also attempted to use masquarading but this only works for locally generated emails... for some reason, it sees localhost as an external host.
My /etc/hosts file has actual domain names configured where even 'localhost' does not appear at all. I've understood in some posts that php is to "blame" for this and their have been suggestions about modifying the PHP scripts etc (they weren't specific to Drupal)
Has anyone come across this problem, and what did you do to correct it?
Thanks.
Best Regards,
Steve
Comments
Comment #1
Frameshift commentedOk... its amazing to me that so many posts appear on the 'net asking for help to rectify this very issue, but scant information on how to do it.
Well I think I discovered the reason. So hopefully Google will index these posts to help others in the future.
The problem is that the line in the header "Received: (from apache@localhost) by..." WILL cause many ISPs to drop emails containing this line. I discovered this first hand as about 20% of my users who signed up, never got the email. Parsing the logs shows the rejects.
In /etc/php.ini, sendmail is defined as the mail program to use to send these emails. Apparently, when this is invoked, the current running sendmail instance that receives the email, sees the connection as coming from a foreign mailserver from a foreign domain, not local.. even though its on the same machine with localhost as the domain. Any and all rewrite mechanisms worked, but the key was in the log file itself, where the initial log entry for the message noted "relay=apache@localhost" This denotes a server and not a recipient or sender, so it never got rewritten.
After talking to a few people (one of whom had rather choice words for Sendmail), I switched to Postfix. Now I still saw the initial "Received" message until I found a note that spoke of editing php.ini with the following line: "sendmail_path = /usr/sbin/sendmail.postfix -t -i" Postfixers will know what this is, and for those that don't, its a sendmail compatibility program for Postfix integration, with all the flags/options sendmail has. Once I replaced this line, the "apache@localhost" headers were no more.
One other thing about Postfix... I got this up and running in about an hour. I have other domains to configure on my install, so it remains to be seen how this will go in that type of environment but initially, its worked as advertised, without all the esoteric, straight-jacket, drooling til the thorazine kicks in... issues and recursive "features" of sendmail. And I'm sure the postfix book weighs a lot less too. Kudos to Wietse Venema... (who many years ago along with Dan Farmer wrote the original security scanner "SATAN".. which later morphed into "SAINT")
Comment #2
Frameshift commentedUpdate:
I configured the virtual domains I needed... and it took 10 minutes. I guess I'll be throwing away my 'bat' book. I'm sold on Postfix.
...Now if only dovecot were this easy...
Comment #3
ainigma32 commentedThanks for the writeup Frameshift. Setting this to fixed.
- Arie
Comment #5
tacomadata commentedI'm not sure if I can post since it appears this is closed as fixed.
Switching MTA's will not work in my situation. Instead I got this working using the -G switch with in the sendmail command in php.ini.
In my case, I could send mail from the command line as 'root' but mail would not go out from the apache@localhost account.
sendmail -G root@local (relay to the root account) and things started working.
Comment #6
ace4love commentedWow.. in my case I was trying to get a php script to send mail from my webserver through sendmail. I fought with this all night and most of the day today. Thank God I came across this post!! The -G option in sendmail worked!!
Thank you! Thank you! Thank you!!!!