Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sending multipart mail with wp_mail (untested)
<?php
$to = "receipt@domain.com";
$subject = "My Multipart test";
$message = "I am the plain text message";
$boundary = uniqid(rand(), true);
$header = "MIME-Version: 1.0\n"
$header .= "Content-Type: multipart/alternative; boundary=\"$boundary\"\n";
$multipart_message = "
--$boundary
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
$message
--$boundary
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
<html>
<head>
<style type=\"text/css\">
</style>
</head>
<body style=\"margin: 0; padding: 0; background: #fff;-webkit-text-size-adjust:100%;\">
<span style=\"color: white; font-size: 12px; display: none;\">$message</span>
</body>
</html>
--$boundary--
";
wp_mail( $to, $subject, $multipart_message, $header );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment