phpmailerHow do I set the connection timeout for PHPMailer?
The connection timeout for PHPMailer can be set using the Timeout property. This property takes an integer that sets the timeout in seconds.
For example, to set the timeout to 5 seconds, the code would be:
$mail->Timeout = 5;
The connection timeout can also be set using the SMTPOptions property. This property takes an array of options which can include a timeout setting.
For example, to set the timeout to 10 seconds, the code would be:
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
),
'timeout' => 10
);
The parts of the code are:
$mail: The PHPMailer instanceTimeout: The property used to set the timeout in secondsSMTPOptions: The property used to set an array of options, including the timeoutssl: An array of SSL optionsverify_peer: A boolean option to verify the peer's SSL certificateverify_peer_name: A boolean option to verify the peer's nameallow_self_signed: A boolean option to allow self-signed certificatestimeout: An integer option to set the timeout in seconds
Helpful links
More of Phpmailer
- How do I use PHPMailer to attach a ZIP file?
- How can I configure PHPMailer to support Polish characters?
- How can I use PHPMailer without SMTP secure?
- How can I use PHPMailer with XAMPP on a localhost?
- How can I use PHPMailer with Mailtrap?
- How can I send emails using PHPMailer without using SMTP?
- How can I configure PHPMailer to work with GoDaddy?
- How do I use PHPMailer to send a file?
- How can I use PHPMailer to send emails with a Yahoo account?
- How can I set a timeout for PHPMailer SMTP?
See more codes...