The SMTP Transport
The SMTP Transport sends messages over the (standardized) Simple Message Transfer Protocol. It can deal with encryption and authentication.
The SMTP Transport, Swift_SmtpTransport is without doubt the most commonly used Transport because it will work on 99% of web servers. [1] All the server needs is the ability to connect to a remote (or even local) SMTP server on the correct port number (usually 25).
SMTP servers often require users to authenticate with a username and password before any mail can be sent to other domains. This is easily achieved using Swift Mailer with the SMTP Transport.
SMTP is a protocol – in other words it's a "way" of communicating a job to be done (i.e. sending a message). The SMTP protocol is the fundamental basis on which messages are delivered all over the internet 7 days a week, 365 days a year. For this reason it's the most "direct" method of sending messages you can use and it's the one that will give you the most power and feedback (such as delivery failures) when using Swift Mailer.
Because SMTP is generally run as a remote service (i.e. you connect to it over the network/internet) it's extremely portable from server-to-server. You can easily store the SMTP server address and port number in a configuration file within your application and adjust the settings accordingly if the code is moved or if the SMTP server is changed.
Some SMTP servers – Google for example – use encryption for security reasons. Swift Mailer supports using both SSL and TLS encryption settings.
-
Using the SMTP Transport
The SMTP Transport is easy to use. Most configuration options can be set with the constructor. -
Encrypted SMTP
You can use SSL or TLS encryption with the SMTP Transport by specifying it as a parameter or with a method call. -
SMTP with a Username and Password
Some servers require authentication. You can provide a username and password with setUsername() and setPassword().