Home arrow PHP arrow Handling Attachments and Sending HTML Email Messages with Swift Mailer

Handling Attachments and Sending HTML Email Messages with Swift Mailer

In this sixth article of a series I discuss how to handle file attachments and sending HTML email messages with the Swift Mailer library. As you'll soon see, performing these tasks is a very straightforward process.

TABLE OF CONTENTS:
  1. Handling Attachments and Sending HTML Email Messages with Swift Mailer
  2. Sending copies with the setCc() and setBcc() methods
  3. Handling file attachments with Swift Mailer
  4. Sending email messages in HTML with the addPart() method
By: Alejandro Gervasio
Rating: starstarstarstarstar / 1
February 22, 2010

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

If you're an experienced PHP developer, then you know that coding functions or classes that send MIME email is one of those things that you want to do only once in your lifetime. This process often requires dealing indirectly (or directly, when programming TCP sockets) with the complexities of the SMTP protocol, which admittedly isn't exactly fun. 

To help you avoid this annoying task, there are generous souls that have developed a nice variety of libraries that let you build email applications very quickly and with only minor effort. At this point, it's quite probable that you've tried PEAR Mail, or a similar package, which does a good job of sending MIME email with PHP.

However (and this is only my personal opinion), there's another email library that's much better than PEAR's, since it combines a flat learning curve with a great API, plus a clever implementation of some popular design patterns. Yes, as you might have guessed from this article's title, I'm talking about Swift Mailer, a powerful package created by Chris Corbin that allows you to develop email programs with ease, using a strict object-oriented interface.

Naturally, if you've been a patient reader and have already gone through all of the articles that precede this one, then you now have a clear idea of how to utilize some of the classes provided by Swift Mailer to send basic email messages using different SMTP transports, or how to reach multiple recipients by means of Bcc and Cc MIME headers.

Nonetheless, the real fun is just about to start, since Swift Mailer allows you to manipulate file attachments in all sorts of clever ways, not to mention its remarkable capabilities for sending email messages in HTML format. Thus, in this part of the series, I'm going to explain how to use the library for handling attachments in a basic way, and show you how to send HTML email with it as well.

Now, let's leave the boring theory behind and continue exploring the numerous features of Swift Mailer. Let's go!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap

Dev Shed Tutorial Topics: