php-swiftmailerHow to enable encryption in Swiftmailer?
Swiftmailer supports encryption through the use of Transport Layer Security (TLS) and Secure Sockets Layer (SSL). To enable encryption, you need to set the encryption option in the transport configuration.
// Create the Transport
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
->setUsername('your username')
->setPassword('your password')
->setEncryption('tls')
;
The above example code will enable TLS encryption for the transport. You can also use ssl
instead of tls
to enable SSL encryption.
Swift_SmtpTransport
: Creates a new SMTP transport instance.setUsername
: Sets the username to authenticate with.setPassword
: Sets the password to authenticate with.setEncryption
: Sets the encryption type (tls
orssl
).
Helpful links
More of Php Swiftmailer
- How to set timeout with 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...