php - PHPMailer 在点击提交按钮时将电子邮件发送到不同的地址和不同的正文
问题描述
$autoemail = new PHPMailer\PHPMailer\PHPMailer();
$autoemail->IsSMTP(); // send via SMTP
$autoemail->CharSet="utf-8";
$autoemail->WordWrap = 50; // set word wrap
$autoemail->IsHTML(true); // send as HTML
$autoemail->AddAddress("example@gmail.com");
$autoemail->AddReplyTo("example@gmail","EXAMPLE");
$autoemail->WordWrap = 50;
$autoemail->Subject="Hello";
$autoemail->Body="Testing only";
if(!$autoemail->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $autoemail->ErrorInfo;
exit;
}
$autoemail->ClearAllRecipients();
$autoemail->AddAddress("pleasehelp@gmail.com", "EXAMPLE");
$autoemail->Body="Testing Only";
if(!$autoemail->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $autoemail->ErrorInfo;
exit;
}
我想向两个不同的电子邮件地址发送电子邮件,但是这种编码给了我错误,它向两个地址发送了两次电子邮件,并且在发送电子邮件后,我的网页变成了白页,说它有错误 ERR_INCOMPLETE_CHUNKED_ENCODING。请帮我解决这个问题!谢谢!
解决方案
您的代码看起来不错,但您可能有一个浏览器插件或导致多次提交的东西。如果您在主题行的末尾粘贴一个随机数,我希望您会发现每组消息它们会有所不同,这表明脚本多次运行,如下所示:
$autoemail->Subject="Hello".rand();
查看您的访问日志也可能会显示多个请求。
分块编码错误似乎与此脚本无关。
推荐阅读
- git - 为什么不能提交和推送源树?
- haskell - 圆形素数
- c# - Elasticsearch Nest SDK 接受无效 JSON 的查询?
- python - 如何使用依赖于 AVI 文件的 python 打开 exe 文件?
- android - 在 log cat 中获取以下日志
- laravel - 可以在 laravel 中执行 PERCENTILE.EXC 吗?如果是怎么办?
- android - 登录后在警报对话框中显示登录用户信息
- php - 如何在php中将特殊字符串转换为数组
- extjs - 如何在 ExtJS7 中实现无线电组
- python - 是否可以通过溢出从 div 中的 div 获取数据:隐藏在 python 的请求中?