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" <admin@senygma.com>' . "\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");

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.