Sending emails using PHPMailer and an SMTP service provider like Amazon SES, Gmail, and SendGrid can sometimes be very slow. It can take one to 60 seconds for emails to start sending.

Problem: PHPMailer Very Slow

Using email-sending libraries like PHPMailer is convenient to many users because of how easy it is to securely send emails using a custom SMPT provider. However, if PHPMailer is not well configured, it can take longer to send emails resulting in a bad user experience.

Solution: Change PHPMailer’s Mailer property

To fix PHPMailer sending emails at a very slow speed, open your email processing script.  Then look for this line in your script, ‘$mail->IsSMTP()‘, and replace it with ‘$mail->IsMail()‘.  You can also use ‘$mail->isSendmail()‘ if ‘$mail->IsMail()‘ does not work.

The problem with using IsSMTP() over IsMail(), is that SMTP takes many round-trips before sending emails. This leads to delays. IsMail() mailer property cuts down the trips as it uses your hosting provider’s PHP mail function. This significantly improves email-sending speed. Additionally, popular web hosting companies will not allow you to send emails with PHPMailer using IsSMTP.

The downside of using IsMail() over IsSMTP() is that most Windows servers do not support isMail. You may also encounter email-sending limits since you are using your hosting provider’s mail functions to send emails.

The solutions above fixed a problem that we were facing.