MBF Knowledge Base

I'm using PHPMailer and I set the SMTP Timeout option to a value of 5. However, the SMTP timeout takes much longer and doesn't cancel after 5 seconds. How can I fix this?

There are two timeouts in PHPMailer's SMTP class - Timeout and Timelimit.

Timeout applies when making the initial TCP connection. Timelimit is the duration allowed for each SMTP command's response. Both default to 5 minutes (in accordance with the RFCs) - so it could be that you are connecting quickly, but then the server is very slow to respond to commands. You should try setting the Timelimit to a lower value like this:

$mail->getSMTPInstance()->Timelimit = 5;