Join David Powers for an in-depth discussion in this video What is Swift Mailer?, part of PHP: Email with Swift Mailer.
- Let's start by taking a general look at what Swift Mailer is and what it does. It's a PHP library that you incorporate into your own applications to send email. It's rich in features designed to overcome the shortcomings of the PHP mail function. Swift Mailer was originally created in 2005 by Chris Corbyn. But since 2009, it's been maintained by Fabien Potencier of Symfony, one of the most widely used and advanced PHP frameworks.
Although the Swift Mailer bundle is part of the standard Symfony framework, the Swift Mailer library is a stand-alone component that can be used independently of Symfony. And that's how we'll be using Swift Mailer in this course. You don't need to know anything about Symfony. So what's wrong with the PHP mail function? Well, for a start, it's extremely basic. It doesn't support connection to a mail server that requires authentication with a username and password.
Nor does it support attaching files to an email. It's unsuitable for sending multiple emails in a loop because it opens and closes a socket every time it's invoked. And there's no information about how many messages were sent or if some addresses failed. Swift Mailer fills in these gaps. It supports SMTP authentication with a username and password. It also supports HTML email and file attachments.
You can even request a receipt when the recipient reads the email. And if your application deals with bulk mailings, as well as individualizing the greeting and other information for each recipient, you can control the pace at which the mails are sent to avoid limits imposed by the server. Swift Mailer also provides improved feedback, including a logging feature for debugging problems. Best of all, Swift Mailer is easy to use.
Swift Mailer is free and feature-rich, and it integrates into any web app written in PHP 5 or 7. Swift Mailer offers a flexible and elegant object-oriented approach to sending emails, including HTML email and bulk email. This PHP tutorial guides developers through the process of installing and loading Swift Mailer, and sending emails using SMTP and encrypted SMTP connections. David Powers teaches secure methods that protect users and support MIME standards. He also introduces advanced techniques for sending attachments, personalizing email, and limiting the send rate. Want to see how Swift Mailer solves a real-world programming challenge? Chapter 6 is a case study that shows how to use Swift Mailer to send an email registration form.
- What is Swift Mailer?
- Installing Swift Mailer
- Preparing basic email
- Sending email via SMTP
- Handing off emails to mail transport agents
- Sending attachments
- Sending HTML email
- Personalizing bulk mail
- Limiting the rate of sending emails