为什么从 PHP-Mailer 发送电子邮件很慢
Why Sending Email From PHP-Mailer is Slow
我正在使用 PHP-Mailer。
它工作正常,但发送电子邮件非常慢。
就像发送 email.but 需要花费 1 秒的时间,大多数情况下需要 2 分钟或更长时间,有时需要 30 分钟。
有没有其他电子邮件发送方法。
或在 3 秒或 10 秒内发送邮件的任何方式。
$mail->Timeout = 36000;
$mail->Subject = "Registration";
$mail->From = "info@educatorguru.com";
$mail->FromName = "Educatorguru.com";
$mail->AddReplyTo( "info@educatorguru.com" );
$mail->AddAddress( $email );
$mail->Body =$message2;
$mail->IsHTML(true);
$mail->Send();
PHPMailer wiki 有 an article on maximising performance when sending in volume,但类似的措施也有助于单个消息。
使用您发布的代码,这意味着您正在使用 PHP 的 mail()
函数发送,该函数使用 sendmail 二进制文件打开与本地主机的同步 SMTP 连接 - 您可以帮助调试将此添加到您的脚本中实际上阻碍了什么:
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->SMTPDebug = 2;
这将产生大量带有时间戳的调试输出,因此您将能够看到哪个部分比较慢。
另一种方法是不以交互方式发送 - 将您的消息存储在 'to do' list/queue 中并获得一个 cron 作业或其他进程来接收消息并异步发送它们 - 这意味着您的页面可以立即 return,无需等待消息发送。
这是因为我的托管服务器速度慢,这就是它发送慢速电子邮件的原因。
现在我改变了我的托管服务器。
现在它工作得很好谢谢大家
我正在使用 PHP-Mailer。 它工作正常,但发送电子邮件非常慢。 就像发送 email.but 需要花费 1 秒的时间,大多数情况下需要 2 分钟或更长时间,有时需要 30 分钟。 有没有其他电子邮件发送方法。 或在 3 秒或 10 秒内发送邮件的任何方式。
$mail->Timeout = 36000;
$mail->Subject = "Registration";
$mail->From = "info@educatorguru.com";
$mail->FromName = "Educatorguru.com";
$mail->AddReplyTo( "info@educatorguru.com" );
$mail->AddAddress( $email );
$mail->Body =$message2;
$mail->IsHTML(true);
$mail->Send();
PHPMailer wiki 有 an article on maximising performance when sending in volume,但类似的措施也有助于单个消息。
使用您发布的代码,这意味着您正在使用 PHP 的 mail()
函数发送,该函数使用 sendmail 二进制文件打开与本地主机的同步 SMTP 连接 - 您可以帮助调试将此添加到您的脚本中实际上阻碍了什么:
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->SMTPDebug = 2;
这将产生大量带有时间戳的调试输出,因此您将能够看到哪个部分比较慢。
另一种方法是不以交互方式发送 - 将您的消息存储在 'to do' list/queue 中并获得一个 cron 作业或其他进程来接收消息并异步发送它们 - 这意味着您的页面可以立即 return,无需等待消息发送。
这是因为我的托管服务器速度慢,这就是它发送慢速电子邮件的原因。 现在我改变了我的托管服务器。 现在它工作得很好谢谢大家