Join David Powers for an in-depth discussion in this video Sending individually addressed emails, part of PHP Email with Swift Mailer.
- View Offline
- [Voiceover] Sending the same email…to multiple recipients can seem rather impersonal,…but it's easy to address them individually.…I've opened individual.php in the Chapter Five…05_01 folder of the exercise files.…On lines four to nine is a mixed array called recipients.…Each array element is a variable…that draws an email address from config.php.…And in two cases I've added a name to the email address.…
I want to loop through the recipients array…to send the same email to each one individually.…In the try block, I've created an instance of Swift Message,…set the subject, the from address, the body of the email,…but there's no to address.…The script then initializes an smtp transport…and creates an instance of Swift Mailer.…But there's no code yet to send the emails.…To send the email to individual addresses,…we need to create a loop to iterate…over the recipients array.…
But before doing so, I want to initialize…a couple of variables to keep track of what's going on.…The first one will keep count of the number of emails…
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