php-swiftmailerHow to set timeout with Swiftmailer?
Swiftmailer provides a way to set a timeout for sending emails. This can be done by setting the timeout
parameter in the Transport
configuration.
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
->setTimeout(30);
The above example sets the timeout to 30 seconds.
Code explanation
Swift_SmtpTransport
: This is the transport class used to send emails.smtp.example.org
: This is the SMTP server address.25
: This is the port used to connect to the SMTP server.setTimeout
: This is the method used to set the timeout.30
: This is the timeout value in seconds.
Helpful links
More of Php Swiftmailer
- How to use SMTP with Swiftmailer?
- How to use TLS 1.2 with Swiftmailer?
- How to get the response code when using Swiftmailer?
- How to use Swiftmailer to send RFC 2822 compliant emails?
- How to configure Swiftmailer for Postfix?
- How to send emails in UTF8 using Swiftmailer?
- How to send emails to multiple recipients with Swiftmailer?
- How to set the port for Swiftmailer?
- How to enable TLS with Swiftmailer?
See more codes...