I'm using PhpMailer to send e-mails. It's working fine.
But in some cases I don't want to wait for the send function to return, specially because it can take a while sometimes. I just want to send and finish the funcition right away.
Is it possible to achieve this?
This is a sample code I'm using (nothing different from the basics).
try {
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
// ...other options...
$mail->send();
return true;
} catch (Exception $e) {
return $e;
}
You don't need to use ajax or configure your own queueing system to do this. Just use a local mail server - which implicitly has a built-in queueing system that you don't need to configure - and you can submit messages to it in a fraction of a second. There is some performance advice on the PHPMailer wiki.