Since I moved this blog over to a new web host, there’s been a cosmetic — but annoying — problem with my comment notification emails. I finally figured out how to solve it, and because I devised the solution myself after being unable to find a quick answer on the Web, I thought I’d better document the procedure here. You know, for future reference. Or in case anybody else has this problem.
Okay, the backstory: Whenever somebody comments on a post here, I get an email notification. This is a standard WordPress feature. Normally, the email’s “From” name is that of the person who left the comment, which makes it easy for me to see who it was without even opening the email. But since I moved to a new web host, the “From” name on those emails was my hosting account username instead, and the domain was my shared hosting server — something like “box123.host.com.” Really ugly, and irritating as well because I could no longer see at-a-glance who left a comment.
It was obviously a server-related issue, so I did some Googling, but found little of benefit. The only thing that helped was this post, wherein it was suggested to modify the sendmail_path value in your php.ini file so that a fixed “From” email address is used whenever sendmail is invoked. But this was intended to mitigate sender name mismatches with WordPress’ admin emails, such as the spam moderation messages and new user notifications — not the comment notifications. I didn’t want all of my comment emails coming from my own email address, I wanted them to come from the person who commented. Even so, this solution was better than “firstname.lastname@example.org”, so I gave it a try.
The custom php.ini took care of the admin emails, as expected, but my comment emails were still screwed up. I delved into the logic of this issue a bit further, and compared the headers of comment notification emails from my old host as well as my new host. Apparently, when WordPress sends those comment notifications, it tacks the comment author’s name onto the email, but doesn’t use their email address — it uses a dummy email address called “wordpress” that it doesn’t expect will exist. As a result, the email appears to come from: “Comment Author <email@example.com>”.
Well, that dummy email address was the source of the problem. My server will not allow this type of email header to be created if the “From” email address specified does not actually exist. It does some kind of check to see if <firstname.lastname@example.org> is a valid address, and if it is not, it will show “email@example.com” as the sender instead. All I had to do to mitigate this was create an email forwarder — not even a real account, just a forwarder — called “wordpress” so that the dummy address would be seen as valid. Voila! Now my comment emails are back to normal: They appear to come from the comment’s author.
In addition, this solution makes the aforementioned php.ini hack unnecessary.
By the way, in case you’re wondering, I just blackhole anything sent to that “wordpress” address so that I’ll never see it. Not that I expect anybody to hit “reply” on those notifications and try talking to me, but given that “wordpress” is a known word, random spam attacks might otherwise stumble across it and start bombarding me with crap.
Hope this helps somebody. Or me, in the future. You never know.