Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send asynchronous email with phpmailer

Tags:

phpmailer

Is it possible to send asynchronous emails with phpmailer?

Regular mail sending code snippet is as follows:

$mail->Send();

PHP waits for the Send() to return the result before moving on. Is it possible to have phpmailer to return a result instantly without waiting for the real email sending routine to complete.

like image 667
Haluk Avatar asked Feb 18 '12 14:02

Haluk


People also ask

Does PHPMailer use SMTP?

PHPMailer can use a non-local mail server (SMTP) if you have authentication. Further advantages include: It can print various kinds of error messages in more than 40 languages when it fails to send an email. It has integrated SMTP protocol support and authentication over SSL and TLS.

How many emails can I send with PHPMailer?

PHPMailer does not set any limits, nor does the mail() function, it's only ISPs like GoDaddy that do. However, they do so by blocking access to normal SMTP ports, and/or redirecting SMTP connections to their own servers ( *. secureserver. * ).

What is PHPMailer SMTP?

PHPMailer is a code library, that is integrated` to send emails securely and effectively by means of PHP code from a web server. Sending emails specifically via PHP code uses a high-level environment to setup SMTP standard convention and related issues and vulnerabilities around Mail infusion for spamming.

Can I use PHPMailer in localhost?

The PHPMailer library provides the easiest way to send an email from localhost with an SMTP server using PHP. Not only the text email, but you can also send HTML email from localhost in PHP using PHPMailer.


1 Answers

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.

like image 93
CodeTower Avatar answered Oct 27 '22 00:10

CodeTower