HomePHP Using Different Paths for Attachments with Swift Mailer
Using Different Paths for Attachments with Swift Mailer
Welcome to the seventh tutorial of a series on Swift Mailer. Comprised of ten parts, this series introduces you gently to using this thorough PHP5-based email package. It complements the corresponding theory with numerous code samples that you can incorporate into your own PHP applications.
If you’re a PHP developer who’s looking for an approachable guide that teaches you how to take advantage of the most relevant features provided by the powerful Swift Mailer email library (available at http://swiftmailer.org), then this group of tutorials might be the material that you really need.
Now that you’re aware of the goal of this article series, it’s time to review the topics that were discussed in the last tutorial. In that part of the series I explained how to attach one single file to a simple email message, and how to sent the message in HTML format.
In the first case, the sample file was attached by using a separate class included with Swift Mailer, called “Swift_Attachment,” while the formatting of the message with HTML was done via the “addPart()” method that belongs to the already familiar “Swift_Message" class.
However, the Swift Mailer library has plenty of options for handling files, including the ability to attach them from different locations on the web server and even from remote hosts. So, this seventh installment of the series will be focused on illustrating how to attach a file to an email message from a distinct folder, thus demonstrating the flexibility of the library when manipulating attachments’ paths.
Now, it’s time to leave the preliminaries behind and continue exploring the numerous features offered by Swift Mailer. Let’s jump in!