Investigation completed.OK. It seems that some MTAs ( Mail Transfer Agents ), particularly QMail, do NOT accept the
\n character when breaking apart multiline encoded subject lines. The
\n newline character is NOT something a site owner adds, and this is NOT something that s2Member does either. It's something that the PHPMailer class, which powers the
wp_mail() function does.
This compatibility issue may affect site owners who are hosted by a company that uses QMail to power email functionality on their server, or another MTA who might be picky in this regard. Right now, I'm only aware of QMail. If your hosting company uses QMail, your hosting company may have trouble sending mail processed by
wp_mail(), when/if your email subject line is longer than usual
( i.e. requiring the \n newline character to break it apart during transmission of the email, to the recipient ).
For instance, in this investigation, the customized subject line was:
- Code: Select all
[Rick’s Neuromuscular Friends Forum] New User Registration
PHPMailer, via the
wp_mail() function, will encode this during transmission, to this:
- Code: Select all
=?utf-8?Q?[Rick=E2=80=99s_Neuromuscular_Friends_Forum]_New_User_Registrat?=\n
=?utf-8?Q?ion?=
* Please note, this IS correct behavior. However, for whatever reason, some MTAs will NOT accept this, and the delivery of the email message will fail silently behind-the-scene.
See:
http://code.google.com/p/textpattern/is ... tail?id=38
So, how can you work around this issue?This is difficult for s2Member to do, because the code that affects this compatibility issue is NOT within s2Member's source code, and it's also NOT something s2Member can modify within WordPress itself, given technical challenges related to the way it's implemented by PHPMailer.
Until we discover a way for s2Member to dynamically work around this issue, here are some things you can do yourself to overcome this compatibility issue, when/if it's affecting you.
Solution option #1.Try installing an SMTP mail plugin for WordPress.
See:
http://wordpress.org/extend/plugins/wp-mail-smtp/
Or, solution option #2.When/if you configure s2Member to handle New User Notifications for your installation of WordPress, you have the option of modifying the subject line used in these emails.
Try to reduce the size of your customized subject line; and test again, until your subject line is short enough NOT to require line breaks during email transmission.
How long is too long? Well, this also is difficult to pinpoint, because the length is examined during transmission of the email, and this happens *after* encoding occurs. Thus, depending on the number of special characters in your email message, it could wind up long enough to require newlines during transmission. The best advice I can give, is to avoid the use of special characters all together, and try to keep your subject under 55 chars in length. This should resolve the compatibility issue for you.
Or, solution option #3.Move to a different hosting provider. Perhaps one that uses the most common MTA, which is Sendmail; or one that uses Exim, which also seems to be perfectly compatible with the PHPMailer class.
Or, solution option #4.Open this file from your installation of WordPress.
/wp-includes/class-phpmailer.php at line #644 find this function.
- Code: Select all
protected function MailSend
Find all occurrences of this code snippet inside the MailSend function:
- Code: Select all
$this->EncodeHeader($this->SecureHeader($this->Subject))
Wrap all instances with this:
- Code: Select all
str_replace("\n", "\r", $this->EncodeHeader($this->SecureHeader($this->Subject)))
*This forces
\r in encoded multiline subjects, instead of the default
\n.
In my tests, this fixes the issue on most incompatible MTAs.