Swift Mailer


Open Source Component Based PHP Library

Free PHP API that allows sending emails using SMTP, sendmail, postfix, or a custom Transport implementation. Add content to an email message, attach files on disk or existing files, embed inline media files & so on.

Swift Mailer is a useful component based library that helps software developers to create powerful PHP application for working with e-mails message. Swift Mailer uses various MIME entities while creating email messages and thus makes it easy to create complex messages with little effort. It is open source and released under the MIT License.

The Swift Mailer library can be easily integrated into any PHP web apps. It uses a flexible and graceful object-oriented approach to sending emails with a multitude of features. It covers almost e aspect of sending emails, from setting up different transports to customizing the message that's being sent. It supports sending emails using SMTP, sendmail, postfix, or a custom Transport implementation. The library is secure and protects from header injection attacks without stripping request data content.

The Swift Mailer library has is easy to handle and has included several important features for managing your emails such as adding content to an email message, attach files on disk or existing files, embed inline media files, embed dynamic content, adding multiple recipients, email message encryption support, setting message priority, message encoding support and so on

Previous Next

Getting Started with Swift Mailer

The recommended way to install the Swift Mailer component is via Composer, please use the following command for easy installation.

Install Swift Mailer via GitHub

$ composer require"swiftmailer/swiftmailer:^6.0" 

Create and Send Email Messages via PHP

The open source Swift Mailer library supports creating email messages inside your PHP applications. The library has provided several important features to achieve the task such as adding content to your message body, formatting the content, attaching different kinds of files, embedding dynamically generated content, embed media files into the message, sending an email message to multiple recipients and so.

Send Emails with Attachments via PHP

The free library Swift Mailer allows software programmers to send emails message with attachments from inside their PHP applications. You need to instantiate the Swift_Attachment object and use the attach method to include your attachments. Apart from the file attachments, you can also embed images in the email message text. The library also fully supports the embedding of dynamically generated content without having an existing file available. You can just use one-liner code to embed already existing files or using URL.

Emails Encoding via PHP API

The Swift Mailer library makes it easy for software developers to add encoding capability to their PHP application. The library supports encoding the body of the MIME part of the email message. It also allows encoding the binary attachments using base64. The text parts are encoded using quoted-printable which is a safe choice and most modern SMTP servers support it.

Using Custom Headers to Your Emails

The open source Swift Mailer library enables software programmers to included message headers using PHP commands. The library supports adding a customized header to an email message as well as modify an existing one with ease. Modifying the existing header is a difficult task as there is little difference between the headers. The Swift Mailer library used different types of MIME headers which are categorized into more general groups, such as text headers, parameterized headers, date headers, ID headers and path Headers.