WordPress Problem: Double-Spaced Emails
Posted November 4th, 2006 @ 11:41am by Erik J. Barzeski
I'm having problems with WordPress. Specifically, the email notifications it sends out. Have a look.
This all began when I started monkeying with my own plugin to replace two of WordPress' pluggable functions that send mail, though admittedly this was also at about the same time as the DNS began propagating and the new server started being used to send email over the old server.
The headers are really not out of the ordinary, except that SpamAssassin adds its scoring information:
Return-Path: <anonymous@barzeski.com>
Delivered-To: 1-erik@barzeski.com
Received: (qmail 28558 invoked by uid 48); 4 Nov 2006 11:42:32 -0500
Date: 4 Nov 2006 11:42:32 -0500
Message-ID: <20061104164232.28557@barzeski.com>
To: erik@barzeski.com
Subject: [NSLog();] Please moderate: "WordPress [snip] Emails"
MIME-Version: 1.0
From: wordpress@nslog.com
Content-Type: text/plain; charset="UTF-8"
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on as.barzeski.com
X-Spam-Level:
X-Spam-Status: No, hits=0.3 required=4.0 tests=NO_REAL_NAME autolearn=no version=2.63
I've re-installed WordPress from a fresh download, thinking perhaps I'd changed the line endings in one of the files somehow, but predictably this did not fix things. I've added "wordpress@nslog.com" to my server-wide white list and the SpamAssassin headers are still added (and I'm not certain it's SpamAssassin screwing things up anyway). ((Turning SpamAssassin off entirely results in no change.))
So really, it seems to be something on or about the new server that's causing the problem, as yesterday saw a mix of single- and double-spaced emails (while the DNS was still propagating and some were still seeing the old server). All of today's emails have been double spaced.
Yet I'm not certain what on the new server is causing the problems. It's frustrating to say the least.
Posted 04 Nov 2006 at 3:10pm #
I've been getting that for about a few months now, and assumed it was just a plug-in mucking about, but if it's the server (as is your case), that could clear things up. I'll keep checking this post and the comments it will receive
Posted 04 Nov 2006 at 4:17pm #
What are the strings in the code that generate the email? If the emails are plaintext I'd guess unix line endings will give you one line, whilst windows line endings (crlf) would give you two lines?
Posted 04 Nov 2006 at 4:29pm #
[quote comment="20974"]What are the strings in the code that generate the email? If the emails are plaintext I'd guess unix line endings will give you one line, whilst windows line endings (crlf) would give you two lines?[/quote]
They're \r\n. I had changed them earlier and it seemed to have little effect, but come to think of it, that may have been because I was only uploading the changes to my new server, and some folks were still hitting the old one. Except… I never had any problems with this double-spacing on the old server.
At any rate, replacing \r\n with just \n on the new server fixes things except in the comment itself. There, it's still doubled. I'll try a str_replace and report back.
Posted 04 Nov 2006 at 4:47pm #
[quote comment="20975"]I'll try a str_replace and report back.[/quote]
Adding this in the appropriate location seems to have helped.
$notify_message = str_replace("\r", '', $notify_message);
I had done this in my own code, yet it wasn't working. But again, that's because I was uploading my own code to the new server, yet messages were still being created on the old server.
Time to re-extract these methods into a plugin for my own use.