Mar*_*ney 6 php email mail-form
我在我公司的网站上有一个表格,其中包含姓名,电话号码和评论(以及其他一些内容).注释框允许您键入最多5000个字符 - 这是一个很大的限制,允许非常详细的客户.有效表单的内容使用php表单邮件作为纯文本电子邮件发送给我们的销售部门.
出于某种原因,如果注释超过大约1000个字符,它们将具有感叹号,换行符,有时插入缩进.注意这仅适用于电子邮件; 如果表单中有错误,数据将被插入到表单中并标记错误,并且注释还没有感叹号+换行符.
我找到了一篇关于它的论坛帖子,暗示有大约990个字符的字符限制导致了这个问题.
有谁知道原因?有谁知道一个相当容易的解决方案吗?
相关的PHP代码:
$to = $email;
$subject = "Website Order Received: $offer";
$contents = "
Order Form Received -\n
Name: $name\n
Company: $company\n
Email: $email\n
Phone: $phone $phoneExt\n
Order Contents:\n" .
($offer == 'web-demo' ? "- I want a live software demonstration.\n" : "") .
($offer == 'pricing' ? "- I'd like pricing information.\n" : "") .
($offer == 'holiday-pricing' ? "- I'd like to sign up before December 31st for the special holiday offer!\n" : "") .
($offer == 'bid-help' ? "- Please give me marketing materials and other assistance for winning bids.\n" : "") .
($offer == 'demo-cd' ? "- Send me the full-version demonstration CD.\n" : "");
if (!empty ($comments)) {
$comments = str_replace("
", "\n", $comments); // Preserves line breaks in the comments.
$contents = $contents."\nComments: $comments\n\n";
}
$contents = str_replace("\n", "\r\n", $contents);
mail($to, $subject, $contents);
Run Code Online (Sandbox Code Playgroud)
lon*_*day 10
电子邮件行中的字符数有限制:
此标准对一行中的字符数有两个限制.每行字符必须不超过998个字符,并且不应超过78个字符,不包括CRLF.(RFC 2882)
您可以使用PHP函数wordwrap来实现此目的:
$contents = wordwrap($contents);
Run Code Online (Sandbox Code Playgroud)
无论如何,这将提高您的脚本发送的电子邮件的可读性,并使它们符合标准.
| 归档时间: |
|
| 查看次数: |
2690 次 |
| 最近记录: |