-
Notifications
You must be signed in to change notification settings - Fork 12
Send Messages from Templates
Postmaster gives developers the ability to send emails programmatically right from your templates. The craft.postmaster.send method will create and send a new Postmaster_TransportModel.
service
This is unique id of the service you wish to use to send the message. By default testing will be used.
serviceSettings
A JSON object of settings that will be passed to the service.
settings
A JSON object of settings that will be passed to the settings model, which by default is a Postmaster_EmailModel object.
settingsModel
A change the type of model used to instantiate the settings. The default value is Craft\Postmaster_EmailModel.
data
A JSON object of additional data passed for programmatic purposes to the Postmaster_TransportModel.
senderId
An optional setting to pass a senderId, also used for programmatic purposes. Omit this option if you have no use for it.
sendDate
Set a date in which to send the message. If the message is post-dated for the future, it will be sent to the queue. Omit this option if you wish to send the message immediately.
queueId
If are wanting to send an item from the queue, enter the id here. Most of the time this option does not need to be set.
{% set request = {
settings: {
toName: 'Some Name',
toEmail: 'toEmail@test.com',
fromName: 'Some Name',
fromEmail: 'fromEmail@test.com',
subject: 'Some subject here...',
bodyHtmlTemplate: 'emails/testHtml',
bodyTemplate: 'emails/testPlain',
},
service: 'testing',
serviceSettings: {
}
} %}
{% set response = craft.postmaster.send(request) %}