Send asynchronous email with phpmailer

前端 未结 2 538
深忆病人
深忆病人 2021-01-12 02:43

Is it possible to send asynchronous emails with phpmailer?

Regular mail sending code snippet is as follows:

$mail->Send();

PHP waits

2条回答
  •  遥遥无期
    2021-01-12 03:09

    Update May 2016

    As mentioned by user @Sinak Salek PHP does support multithreading. It is available using the pthreads extension.

    Original

    PHP does not support multithreading natively (which you need to do this beautifully). You can do it though by saving the emails in a database and then process them later using another script (e.g. using a cron job). In this way you don't have to wait for the underlying email framework.

    Another thing, if phpmailer is slow it can be due to the underlying mail program (sendmail, postfix etc.) is setup incorrectly.

提交回复
热议问题