Adding Content to Your Message
Rich content can be added to messages in Swift Mailer with relative ease by calling methods such as setSubject(), setBody(), addPart() and attach().
-
Setting the Subject Line
The subject line, displayed in the recipients' mail client can be set with the setSubject() method, or as a parameter to Swift_Message::newInstance(). -
Setting the Body Content
The body of the message – seen when the user opens the message – is specified by calling the setBody() method. If an alternative body is to be included addPart() can be used. -
Attaching Files
Attachments are downloadable parts of a message and can be added by calling the attach() method on the message. You can add attachments that exist on disk, or you can create attachments on-the-fly. -
Embedding Inline Media Files
Often people want to include an image or other content inline with a HTML message. It's easy to do this with HTML linking to remote resources, but this approach is usually blocked by mail clients. Swift Mailer allows you to embed your media directly into the message.
Parent topic: Creating Messages
Previous topic: Message Basics
Next topic: Adding Recipients to Your Message