我在本地主机上通过php的邮件功能发送了一封长HTML电子邮件。它一直被切断,我无法弄清楚原因。
以下是产生截止电子邮件的代码:
$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'> </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> </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'> </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'> </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'> </td></tr>";
//and on and on for another 40 lines
这是由此产生的电子邮件代码:
<html><body><table rules="all" style="border-color: #666;" cellpadding="10"><tr><td colspan='2'>Application</td></tr><tr><td colspan='2'> </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>my.email@gmail.com</td></tr><tr><td colspan='2'><p> </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'> </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>
正如您所看到的(或者可能不依赖于格式),即使有更多信息,电子邮件也会在大学名称后被切断。
问题是什么? $ message太大了? 本地邮件服务器发送得太快? (我使用随XAMPP安装的Mercury)
由于
答案 0 :(得分:8)
SMTP对行长度有限制,1024或2048列,我不确定。定期将新行(\r\n
)放入您的身体。我建议在每个</tr>
之后。这对表的呈现方式没有影响,但它应该阻止截断。
答案 1 :(得分:0)
检查您的mail()方法,它应该包含您的content-type
,例如:
mail($email, 'Thank You for Contacting PHPglue', $msg, "From: PHPglue@PHPglue.com\r\ncontent-type: text/html");