PHPMailer using Gmail SMTP slow when sending emails

后端 未结 6 1584
礼貌的吻别
礼貌的吻别 2020-12-30 14:17

I found few older threads that have a similar issue but most of them didn\'t have answers or if they had, the suggestions weren\'t relevant in my case.

I had a compl

6条回答
  •  我在风中等你
    2020-12-30 14:52

    From your description I'd guess it looks like DNS caching issue perhaps. You may want to investigate in more details time being spent to resolve DNS record

    • use curl_getinfo for detailed info on time being spent on the connection fo SMTP google, e.g. name lookup time, resolving, etc... see http://www.php.net/manual/en/function.curl-getinfo.php. This will help you to isolate which part of lookup is problematic.
    • to exclude DNS issues you may want to set your DNS IP server to Google's public DNS server 8.8.8.8 or 8.8.4.4 - see https://developers.google.com/speed/public-dns/. If problem still persists, you may have misconfigured your network - then try connecting to SMTP gmail from another computer or hosting to check latency time.

    From application point of view, it might be advisable for you to send emails asynchronously rather than synchronously, meaning via background e.g. CRON job. This is solution suitable if you send say more than 10 emails per hour. Ensures full control over email stack queue, tracking errors, no latency or page crashes for frontend users.

提交回复
热议问题