0

So I have a problem with SMTP mail, I have a Zend Framework 2 application, and when the user signs up on the site I send him an confirmation email.

The problem is that when the user click on submit it takes about 3-5 seconds on page load, and that's because of the smtp email that is sending, if I take the part out which sends the email, the answer is instant.

I'm using SMTP from gmail, do you guys have any tips how to solve this?

1 Answers1

0

Actually, PHP documentation doesn't recommend to use the PHP's mail() function to send an email on page load. Instead, it would be much faster to send emails in background. For example, create the outgoing_mail table in your database, and save your messages there when page is loaded. Then, create a cron scheduled task which runs your PHP script that would enumerate all pending messages and send them in turn. This way, you will have quick page load time and mail sent.

OlegKrivtsov
  • 752
  • 4
  • 9