Download the PHP package thecodingmachine/swift-twig-mail-template without Composer
On this page you can find all versions of the php package thecodingmachine/swift-twig-mail-template. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thecodingmachine/swift-twig-mail-template
More information about thecodingmachine/swift-twig-mail-template
Files in thecodingmachine/swift-twig-mail-template
Package swift-twig-mail-template
Short Description This package contains a implementation of the SwiftMailTemplate interface which use twig to render the mail message.
License MIT
Homepage https://github.com/thecodingmachine/swift-twig-mail-template
Informations about the package swift-twig-mail-template
Swift Twig Mail Generator
This package takes a Twig template and generates a Swift mail from this template.
Installation
Once installed, you can start creating an instance of the SwiftTwigMailTemplate
class.
The SwiftTwigMailTemplate
represents a mail template that can generate Swift mails.
Example
Because we consider that an example is better than everything else...
Start by creating your mail template. Your template should have two blocks:
If you want you can add another block containing your text body. This block is optional since we can get your the text body directly from the html one.
Also, you can create a mail with a text body only (and no HTML):
Now, let's create a SwiftTwigMailTemplate
instance. This object will generate a SwiftMail
from the twig template.
You can also embed images directly into the email by using the embedImage function. By embedding an image into the email, most mail clients will display the image directly without printing the traditional warning.
Note: embedImage expects one parameter: the full path to the image file.
Going further
The SwiftTwigMailTemplate
class has been designed with dependency injection in mind. Instances can be easily put in your container for easy reuse.
Furthermore, the SwiftTwigMailTemplate
class shares a lot with the Swift_Mail
class. You can:
- setting the from address
- setting the from name
- setting the to address
- setting the to name
- setting the Bcc address
- setting the Bcc name
- setting the Cc address
- setting the Cc name
- setting the ReplyTo address
- setting the ReplyTo name
- setting the max line size
- setting the priority
- setting the read receip to
- setting the return path
All versions of swift-twig-mail-template with dependencies
thecodingmachine/swift-mail-template-interface Version ^5.0
twig/twig Version ~1.27 || ~2.0