1. Products
  2.   Email
  3.   PHP
  4.   Swift Mailer

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 very useful component based library that helps software developers to create powerful PHP applications 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 very little effort. It is open source and released under the MIT License.

The Swift Mailer library can be easily integrated into any PHP web app. It uses a very flexible and graceful object-oriented approach to sending emails with a multitude of features. It covers almost every 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 very secure and protects from header injection attacks without stripping request data content.

The Swift Mailer library is very easy to handle and has included several important features for managing your emails such as adding content to an email message, attaching files on disk or existing files, embedding inline media files, embedding 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 Composer

$ composer require "swiftmailer/swiftmailer:^6.0" 

Create and Send Email Messages via PHP

The open source Swift Mailer library has included support for 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, embedding 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 use URL.

Emails Encoding via PHP API

The Swift Mailer library makes it easy for software developers to add encoding capability to their PHP applications. The library has included support for 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 include message headers using PHP commands. The library supports adding a customized header to an email message as well as modifying an existing one with ease. Modifying the existing header is a very difficult task as there is very 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.

 English