PHP Mailer taking over 30 seconds to send a welcome email

后端 未结 2 1058
甜味超标
甜味超标 2021-01-21 10:47

So I am using the PHPMailer library in PHP to send a welcome email when ever my users registered, and it takes so long to do this.

It takes around 30 - 50 seconds to act

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-21 11:02

    Remote SMTP is not really a good thing to use during page submissions - it's often very slow (sometimes deliberately, for greetdelay checks), as you're seeing. The way around it is to always submit to a local (fast) mail server and let it deal with the waiting around, and also handle things like deferred delivery which you can't handle from PHPMailer. You also need to deal with bounces correctly when going that route as you won't get immediate feedback.

    That you can often get away with direct delivery doesn't mean it's a reliable approach.

    To see what part of the SMTP conversation is taking a long time, set $mailer->SMTPDebug = 2; and watch the output (though don't do that on your live site!).

提交回复
热议问题