Created
December 7, 2016 20:45
-
-
Save sergejmueller/10cbb46b94f3177eb7359fdefd5d3809 to your computer and use it in GitHub Desktop.
Email test to check the 102 KB email size limit
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | |
<title>Your Message Subject or Title</title> | |
<style type="text/css"> | |
</style> | |
</head> | |
<body> | |
<table> | |
<tr><td>%%content%%</td></tr> | |
</table> | |
</body> | |
</html> |
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 | |
$emailContent = ''; | |
$emailTemplate = file_get_contents('email.html'); | |
$maxSize = 102*1024; | |
$contentPlaceholder = '%%content%%'; | |
$sizeDifferenze = $maxSize - strlen($emailTemplate) + strlen($contentPlaceholder); | |
for ($i = 1; $i <= $sizeDifferenze / 4; $i++) { | |
$emailContent .= substr( md5(microtime()),rand(0,26),3) . ' '; | |
} | |
$html = str_replace($contentPlaceholder, $emailContent, $emailTemplate); | |
echo $html; | |
echo strlen($html); | |
exit; | |
$to = '[email protected]'; | |
$subject = 'HTML Test'; | |
$headers = "From: [email protected]\r\n"; | |
$headers .= "MIME-Version: 1.0\r\n"; | |
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; | |
echo mail($to, $subject, $html, $headers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment