php-swiftmailerHow to disable delivery in Swiftmailer?
Swiftmailer is a popular library for sending emails in PHP. To disable delivery in Swiftmailer, you can set the disable_delivery
option to true
in the configuration array.
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
->setUsername('your username')
->setPassword('your password')
->setDisableDelivery(true);
This will prevent emails from being sent when using the transport.
Code explanation
Swift_SmtpTransport::newInstance()
: Creates a new instance of the SMTP transport.->setUsername()
: Sets the username for authentication.->setPassword()
: Sets the password for authentication.->setDisableDelivery()
: Sets thedisable_delivery
option totrue
in the configuration array.
Helpful links
More of Php Swiftmailer
- How to log emails sent with Swiftmailer?
- How to use SMTP with Swiftmailer?
- How to configure Swiftmailer for SMTP without authentication?
- Swiftmailer usage example
- How to send emails in UTF8 using Swiftmailer?
- How to set timeout with Swiftmailer?
- How to use Swiftmailer transport?
- How to set the 'from' address in Swiftmailer?
- How to use TLS 1.2 with Swiftmailer?
- How to use Swiftmailer to send RFC 2822 compliant emails?
See more codes...