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 determine which version of PHPMailer I'm using?
- How can I configure PHPMailer to work with GoDaddy?
- How can I use PHPMailer without SMTP secure?
- How do I use PHPMailer to attach a ZIP file?
- How can I configure PHPMailer to support Polish characters?
- How do I use PHPMailer to encode emails in UTF-8?
- How can I set up PHPMailer to use Zimbra SMTP?
- How can I use PHPMailer in Yii 1?
- How can I use PHPMailer to send emails with a Yahoo account?
- How can I use PHPMailer to send emails through Yandex?
See more codes...