Created
October 16, 2018 21:59
-
-
Save tott/a10bebe067d517455e423eb32f7d1d3d to your computer and use it in GitHub Desktop.
Sending multipart mail with wp_mail (untested)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$to = "[email protected]"; | |
$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