user1883901
user1883901

Reputation: 29

php mail is getting cut off

I am sending a long HTML email via php's mail function on my localhost. It is consistently getting cut off and I can't figure out why.

Here's the code producing the cut off email:

$message = "<html><body>";
$message .= "<table rules=\"all\" style=\"border-color: #666;\" cellpadding=\"10\">";
$message .= "<tr><td colspan='2'>Application</td></tr>";
$message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
$message .= "<tr><td colspan='2'>Personal Information</td></tr>";
$message .= "<tr><td>Name</td><td>{$fullname}</td></tr>";
$message .= "<tr><td>Gender</td><td>{$_POST['gender']}</td></tr>";
$message .= "<tr><td>Address</td><td>{$home_address}</td></tr>";
$message .= "<tr><td>Phone</td><td>{$_POST['primary-phone']}</td></tr>";
$message .= "<tr><td>Email</td><td>{$_POST['primary-email']}</td></tr>";
$message .= "<tr><td colspan='2'><p>&nbsp;</p></td></tr>";
$message .= "<tr><td colspan='2'>School Info</td></tr>";
$message .= "<tr><td>Address</td><td>{$school_address}</td></tr>";
$message .= "<tr><td>Phone</td><td>{$school_phone}</td></tr>";
$message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
$message .= "<tr><td colspan='2'>Describe Yourself</td></tr>";
$message .= "<tr><td>Marital Status</td><td>{$_POST['marital-status']}</td></tr>";
$message .= "<tr><td>Spouse's Name</td><td>{$_POST['partner-name']}</td></tr>";
$message .= "<tr><td>College Degree?</td><td>{$_POST['college-degree']}</td></tr>";
$message .= "<tr><td>Graduation Year</td><td>{$_POST['grad-year']}</td></tr>";
$message .= "<tr><td>College Name</td><td>{$_POST['college-name']}</td></tr>";
$message .= "<tr><td>College Major</td><td>{$_POST['major']}</td></tr>";
$message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
$message .= "<tr><td colspan='2'>Employment Info</td></tr>";
$message .= "<tr><td>Employer Name</td><td>{$_POST['current-employer']}</td></tr>";
$message .= "<tr><td>Date Employed</td><td>{$_POST['date-employed']}</td></tr>";
$message .= "<tr><td>Employer Address</td><td>{$employer_address}</td></tr>";
$message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
//and on and on for another 40 lines

And here's the resulting email's code:

<html><body><table rules="all" style="border-color: #666;" cellpadding="10"><tr><td colspan='2'>Application</td></tr><tr><td colspan='2'>&nbsp;</td></tr><tr><td colspan='2'>Personal Information</td></tr><tr><td>Name</td><td>Blake</td></tr><tr><td>Gender</td><td>male</td></tr><tr><td>Address</td><td>My Street<br>Town, IN 12345</td></tr><tr><td>Phone</td><td>555-555-5555</td></tr><tr><td>Email</td><td>[email protected]</td></tr><tr><td colspan='2'><p>&nbsp;</p></td></tr><tr><td colspan='2'>School Info</td></tr><tr><td>Address</td><td>my street<br>my town, IN 12345</td></tr><tr><td>Phone</td><td>555-555-5555</td></tr><tr><td colspan='2'>&nbsp;</td></tr><tr><td colspan='2'>Describe Yourself</td></tr><tr><td>Marital Status</td><td>married</td></tr><tr><td>Spouse's Name</td><td>Emily</td></tr><tr><td>College Degree?</td><td>yes</td></tr><tr><td>Graduation Year</td><td>2008</td></tr><tr><td>College Name</td><td>Purdue</td></tr>

As you can see (or maybe not depending on the formatting) the email is cut off after the college name even though there is plenty more information.

What's the problem? $message too large? local mail server sends too quickly? (I'm using Mercury that came installed with XAMPP)

Thanks

Upvotes: 1

Views: 2424

Answers (2)

StackSlave
StackSlave

Reputation: 10627

Check your mail() method, it should include your content-type, like:

mail($email, 'Thank You for Contacting PHPglue', $msg, "From: [email protected]\r\ncontent-type: text/html");

Upvotes: 0

Barmar
Barmar

Reputation: 780984

SMTP has a restriction on the length of lines, either 1024 or 2048 columns, I'm not sure. Put newlines (\r\n) periodically in your body. I suggest after each </tr>. This will have no effect on the way the table is rendered, but it should prevent the truncation.

Upvotes: 8

Related Questions