Club Troppo, a site that I administer, relies on the cat2email plugin to post certain categories to interested users (there are lots). When I upgraded to WP 2.1, a lot of users began to complain that they were getting improperly formatted files. The headers would be something like this:
Content-type: text/html; charset="UTF-8"
Content-Type: text/plain; charset="UTF-8"
Obviously problematic, as many email programs would then render HTML mails as plain text. Hilarity ensues.
Well first off, there’s a tiny bug in the cat2email code. It should put out ‘Content-Type’, not ‘Content-type’. Fix this and you get a different set of incorrect headers:
Content-Type: text/plain; charset="us-ascii"
Hmm, still useless.
The culprit, it turns out, is WordPress. In 2.1 and 2.2, the wp_mail function was modified to use the PHPMailer class. If you crack open wp-includes/pluggable.php, you’ll see that the wp_mail function always forces conversion to plaintext. Pretty dodgy.
What it ought to do is check for custom headers and work with them. I’ve submitted a patch to the WordPress mob, and if you really need it, see below.
@@ -187,7 +187,15 @@
$phpmailer->Subject = $subject;
$phpmailer->Body = $message;
+ if ( strstr( $headers, 'Content-Type: text/html' ) )
$phpmailer->IsMail(); // set mailer to use php mail()
Update: Looks like a more robust fix is scheduled for WordPress 2.3.