Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sending multipart mail with wp_mail (untested)
$to = "";
$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 = "
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"\">
<style type=\"text/css\">
<body style=\"margin: 0; padding: 0; background: #fff;-webkit-text-size-adjust:100%;\">
<span style=\"color: white; font-size: 12px; display: none;\">$message</span>
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