phpmailer库花费太多时间

问题描述 投票:0回答:1

我正在创建一个脚本,每天向不同的收件人发送10个文件。这些文件的大小最大为15 MB。 phpmailer花费大量时间10到15分钟。因此对我来说变得无法使用。我正在使用gmail smtp。

//Server settings
//$mail->SMTPDebug = SMTP::DEBUG_SERVER;                      // Enable verbose debug output
$mail->SMTPDebug = 0; //Alternative to above constant
$mail->isSMTP();                                            // Send using SMTP
$mail->Host       = 'smtp.gmail.com';                    // Set the SMTP server to send through
$mail->SMTPAuth   = true;                                   // Enable SMTP authentication
$mail->Username   = '[email protected]';                     // SMTP username
$mail->Password   = 'rainfall2016';                               // SMTP password
//$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->SMTPSecure= 'tls';
$mail->Port       = 587;   

有人可以帮助我改善这一点吗?

performance email gmail phpmailer attachment
1个回答
0
投票

不是PHPMailer速度慢,而是您试图在页面加载期间执行固有的慢速操作;您正在传送大约150兆字节的[[每个收件人,这永远不会很快发生。

[在页面加载期间不发送电子邮件-在数据库或队列中保存您需要进行发送的事实,并异步处理发送。

最简单的方法是使用cron作业来拾取发送任务并运行它们。

或者,不通过电子邮件发送文件,而是发送包含指向它们的链接的消息,以便收件人可以更有效地通过HTTP下载文件。电子邮件根本不是发送大型文件的有效方法。

© www.soinside.com 2019 - 2024. All rights reserved.