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 can I use PHPMailer in Yii 1?
- How do I configure the timeout settings for PHPMailer?
- How can I use PHPMailer to send emails through Outlook?
- How can I configure PHPMailer to work with GoDaddy?
- How can I use PHPMailer without SMTP secure?
- How do I use PHPMailer with OAuth 2.0?
- How can I resolve the issue of my PHPmailer username and password not being accepted?
- How do I configure PHPMailer to use TLS 1.2?
- How do I configure PHPMailer to use SSL?
- How do I configure PHPMailer to use a proxy?
See more codes...