Skip to content

Instantly share code, notes, and snippets.

@natejacobson
Last active August 29, 2015 14:16
Show Gist options
  • Save natejacobson/756bbb4feec3d00d5890 to your computer and use it in GitHub Desktop.
Save natejacobson/756bbb4feec3d00d5890 to your computer and use it in GitHub Desktop.
PHP Mailer for Sending Test HTML Emails to Multiple Clients
<?php
$url = "http://example.com/email.html";
if ( $_GET["url"] != "" ) { $url = $_GET["url"]; }
// Determine Recipients
$recipients = $_GET["to"];
$to = "[email protected]";
// Desktop Clients
if ($recipients == "mail") { $to = "[email protected]"; } // Apple Mail (Gold Standard)
if ($recipients == "thunderbird") { $to = "[email protected]"; } // Standard HTML parsing (Golden)
if ($recipients == "outlook-pc") { $to = "[email protected]"; } // Outlook Desktop PC (Spawn of Satan)
if ($recipients == "outlook-mac") { $to = "[email protected]"; } // Outlook for Mac (Tolerable HTML rendering)
// Mobile Clients
if ($recipients == "ios") { $to = "[email protected]"; } // iOS Mail (Gold Standard, again)
if ($recipients == "android") { $to = "[email protected]"; } // Android Email (Unknown)
if ($recipients == "gmail-android") { $to = "[email protected]"; } // Gmail on Android (Assuming the worst)
if ($recipients == "gmail-ios") { $to = "[email protected]"; } // Gmail on Android (Dreadful, real estate thief. Quit messing.)
// Web Clients
if ($recipients == "yahoo") { $to = "[email protected]"; } // Yahoo (Problem Child)
if ($recipients == "aol") { $to = "[email protected]"; } // Aol (Pretty Decent Web client)
if ($recipients == "facebook") { $to = "[email protected]"; } // Facebook (Pretty Good, Lightboxed)
if ($recipients == "outlook") { $to = "[email protected]"; } // (Reasonably compliant Web email client)
if ($recipients == "gmail") { $to = "[email protected]"; } // Gmail (Problem Child)
if ($recipients == "aol") { $to = "[email protected]"; } // AOL
if ($recipients == "yahoo") { $to = "[email protected]"; } // Yahoo
// Groups
if ($recipients == "group") { $to = "[email protected], [email protected], [email protected]"; } // 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 protected]";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Email Tester <[email protected]>\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