我正在使用
PHPMailer发送效果很好的电子邮件.但问题是,由于它同步发送电子邮件,后续页面加载需要很长时间.
我想知道是否有办法使电子邮件传递异步.我对此进行了研究,发现sendmail可以选择将DeliveryMode设置为“后台模式” – 来源http://php.net/manual/en/function.mail.php
mail($to, $subject, $message, $headers, 'O DeliveryMode=b');
我想知道在PhpMailer中是否可以做类似的事情?有人有这个成功吗?
/**
* Which method to use to send mail.
* Options: "mail", "sendmail", or "smtp".
* @type string
*/
public $Mailer = 'mail';
/**
* The path to the sendmail program.
* @type string
*/
public $Sendmail = '/usr/sbin/sendmail';
/**
* Whether mail() uses a fully sendmail-compatible MTA.
* One which supports sendmail's "-oi -f" options.
* @type boolean
*/
public $UseSendmailOptions = true;
/**
* Send messages using $Sendmail.
* @return void
*/
public function isSendmail()
{
$ini_sendmail_path = ini_get('sendmail_path');
if (!stristr($ini_sendmail_path, 'sendmail')) {
$this->Sendmail = '/usr/sbin/sendmail';
} else {
$this->Sendmail = $ini_sendmail_path;
}
$this->Mailer = 'sendmail';
}
我更喜欢这样做作为api调用vs php.ini的内联参数,所以这不是一个全局变化.有没人试过这个?