Jump to content

Can't properly send HTML emails that are more than about 1000 chars


labeno

Recommended Posts

Hi,

 

I'm trying to send HTML emails using PHP. As long as the HTML email is very small, it works fine. Once the HTML is slightly larger, then it still sends an email, but when the recipient views the email, it's empty.

 

Here's a great example that shows the exact problem. This PHP script sends two emails, the first is small, and the second is a bit larger, but just extra duplication from the small email to prove there's nothing wrong inside of the html.

 

Any help is appreciated.

Michael

 

Here's the PHP script (don't forget to insert your email address so you can see the results):

 

<?PHP

$table_row = "<tr><td style=\"color:#ffffff; background-color:#000033; text-align:center\"><b>Column1</b></td><td style=\"color:#ffffff; background-color:#000033; text-align:center\"><b>Column2</b></td><td style=\"color:#ffffff; background-color:#000033; text-align:center\"><b>Column3</b></td><td style=\"color:#ffffff; background-color:#000033; text-align:center\"><b>Column4</b></td></tr>";

$large_email_body = "<html><body><table border=\"1\" bgcolor=\"#ccccee\" cellpadding=\"3\" cellspacing=\"0\">";
$large_email_body .= $table_row;
$large_email_body .= $table_row;
$large_email_body .= $table_row;
$large_email_body .= "</table></body></html>";

$small_email_body = "<html><body><table border=\"1\" bgcolor=\"#ccccee\" cellpadding=\"3\" cellspacing=\"0\">";
$small_email_body .= $table_row;
$small_email_body .= $table_row;
$small_email_body .= "</table></body></html>";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: "GolfCard Team" <[email protected]>' . "\r\n";

$recipient     = "<your_email_address_here>";
$small_subject = "small html email";
$large_subject = "large html email";

// send small email
if (!mail($recipient, $small_subject, $small_email_body, $headers)) {
  exit("ERROR:Failed to send small email.");
}

// send small email
if (!mail($recipient, $large_subject, $large_email_body, $headers)) {
  exit("ERROR:Failed to send large email.");
}

exit("SUCCESS");

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.