Home arrow PHP arrow Dynamically Attaching Files with Swift Mailer

Dynamically Attaching Files with Swift Mailer

In this eighth part of a ten-part series on the Swift Mailer email library, you'll learn how to attach files that have been dynamically generated to an email message. In addition, you'll see how to use Swift Mailer's "setFileName()" method to modify the name of an attachment before it's sent, which speaks for itself about this library's flexibility.

  1. Dynamically Attaching Files with Swift Mailer
  2. Review: handling attachments with Swift Mailer
  3. Attaching dynamically-generated files
  4. Dynamically changing the name of an attachment
By: Alejandro Gervasio
Rating: starstarstarstarstar / 1
February 24, 2010

print this article



In case you haven’t heard about it yet, Swift Mailer is a comprehensive library written in PHP 5 and freely available at http://swiftmailer.org. It allows you to develop email applications very quickly and with minor effort, through a cohesive and highly intuitive programming interface.

So, if you’re a PHP developer interested in taking advantage of the most relevant features provided by this solid email package, or simply want to take a quick look at what it can do for you, then start reading this series of articles right now!

Being one of the most powerful email packages available nowadays that really uses a strict object-oriented approach and a correct implementation of some popular design patterns, Swift Mailer will let you perform all sorts of clever tasks when building email programs with PHP. These include sending email messages in HTML, handling inline attachments, manipulating MIME headers with ease, and so forth.

And now that I've talked about handling attachments with Swift Mailer, I left off the last tutorial discussing how to use the “Swift_Attachment” class included with the library to attach a single file to an email message first from a local server, and then from a remote host.

Thanks to the intrinsic flexibility given by the “fromPath()” method that belongs to the handy “Swift_Attachment” class, not only is it possible to perform these tasks with attachments, but it’s also feasible to achieve even more useful things with them, such as changing their names on the fly or embedding a dynamically-generated file into an email message.

Sounds pretty interesting, right? So, in this eighth part of the series I’m going to explain, as usual with a decent number of code samples, how to perform the previous attachment operations in a few simple steps.

Are you ready to keep learning more about the Swift Mailer library? Then click on the link below and read the next lines!

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates


Dev Shed Tutorial Topics: