Check to see if you can hook into phpmailer_init and set AltBody
.
add_action('phpmailer_init', 'add_plain_text');
function add_plain_text($phpmailer)
{
$phpmailer->AltBody = "This is a text message";
}
Bonus: pass your HTML through premailer.dialect.ca to render a usable text version and find more info on multipart email at Things I’ve Learned About Building & Coding HTML Email Templates.
Update:
Postman’s test email is an example of a message that has both text and
html parts. It’s content type is “multipart/alternative” which is a
MIME extension.
According to this support question on Postman SMTP Mailer the answer lies in the Postman’s test email and sites this example. Just be sure to replace mail
with wp_mail
.
//specify the email address you are sending to, and the email subject
$email="[email protected]";
$subject="Email Subject";
//create a boundary for the email. This
$boundary = uniqid('np');
//headers - specify your from email address and name here
//and specify the boundary for the email
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: Your Name \r\n";
$headers .= "To: ".$email."\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
//here is the content body
$message = "This is a MIME encoded message.";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
//Plain text body
$message .= "Hello,\nThis is a text email, the text/plain version.
\n\nRegards,\nYour Name";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/html;charset=utf-8\r\n\r\n";
//Html body
$message .= "
Hello,
This is a text email, the html version.
Regards,
Your Name";
$message .= "\r\n\r\n--" . $boundary . "--";
//invoke the PHP mail function
wp_mail('', $subject, $message, $headers);