Last active
August 29, 2015 14:16
-
-
Save natejacobson/756bbb4feec3d00d5890 to your computer and use it in GitHub Desktop.
PHP Mailer for Sending Test HTML Emails to Multiple Clients
This file contains 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 | |
$url = "http://example.com/email.html"; | |
if ( $_GET["url"] != "" ) { $url = $_GET["url"]; } | |
// Determine Recipients | |
$recipients = $_GET["to"]; | |
$to = "default.recipient@example.com"; | |
// Desktop Clients | |
if ($recipients == "mail") { $to = "mail.user@example.com"; } // Apple Mail (Gold Standard) | |
if ($recipients == "thunderbird") { $to = "thunderbird@mozilla.com"; } // Standard HTML parsing (Golden) | |
if ($recipients == "outlook-pc") { $to = "outlook.user@microsoftexchange.com"; } // Outlook Desktop PC (Spawn of Satan) | |
if ($recipients == "outlook-mac") { $to = "outlook.pc@microsoftexchange.com"; } // Outlook for Mac (Tolerable HTML rendering) | |
// Mobile Clients | |
if ($recipients == "ios") { $to = "ios.user@example.com"; } // iOS Mail (Gold Standard, again) | |
if ($recipients == "android") { $to = "android.user@example.com"; } // Android Email (Unknown) | |
if ($recipients == "gmail-android") { $to = "gmail-android.user@example.com"; } // Gmail on Android (Assuming the worst) | |
if ($recipients == "gmail-ios") { $to = "gmail-ios.user@example.com"; } // Gmail on Android (Dreadful, real estate thief. Quit messing.) | |
// Web Clients | |
if ($recipients == "yahoo") { $to = "nbjacobson@yahoo.com"; } // Yahoo (Problem Child) | |
if ($recipients == "aol") { $to = "aol.user@aol.com"; } // Aol (Pretty Decent Web client) | |
if ($recipients == "facebook") { $to = "facebook.user@facebook.com"; } // Facebook (Pretty Good, Lightboxed) | |
if ($recipients == "outlook") { $to = "outlook.user@outlook.com"; } // (Reasonably compliant Web email client) | |
if ($recipients == "gmail") { $to = "gmail.user@yahoo.com"; } // Gmail (Problem Child) | |
if ($recipients == "aol") { $to = "aol.user@aol.com"; } // AOL | |
if ($recipients == "yahoo") { $to = "yahoo.user@yahoo.com"; } // Yahoo | |
// Groups | |
if ($recipients == "group") { $to = "tester1@example.com, tester2@example.com, tester3@example.com"; } // Group | |
// Get the HTML | |
$crl = curl_init(); | |
$timeout = 5; | |
curl_setopt ($crl, CURLOPT_URL,$url); | |
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); | |
$ret = curl_exec($crl); | |
curl_close($crl); | |
$html = $ret; | |
echo $html; | |
// Send the Email | |
$time = date('h:i:s'); | |
$subject = "HTMail ".$time.""; | |
$subject = "HTMail: Happy and Warm ".$time.""; | |
$message = $html; | |
$from = "email.designer@example.com"; | |
$headers = "MIME-Version: 1.0\r\n"; | |
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; | |
$headers .= "From: Email Tester <email.designer@example.com>\r\n"; | |
mail($to,$subject,$message,$headers); | |
echo "Mail Sent."; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment