v1.0.0
Search
K

EmailProvider

The EmailProvider sends notifications using cbMailServices.

Requirements

To use the EmailProvider, you need cbMailServices installed. This is not installed by Megaphone. If you do not have cbMailServices installed, an exception will be thrown if you try to define a channel with the EmailProvider.

Configuration

The EmailProvider accepts the following properties:
{
"mailer": "default",
"onSuccess": () => {},
"onFailure": () => {}
}

toEmail

The toEmail method returns a Mail@cbmailservices instance to send. The to property can be either defined in the toEmail method or a routeNotificationForEmail method defined on the Notifiable instance.
public struct function toEmail( notifiable, newMail ) {
return newMail(
to = notifiable.getEmail(),
subject = "Megaphone Email Notification",
type = "html",
bodyTokens = { product: "ColdBox" }
).setBody( "
<p>Thank you for downloading @product@, have a great day!</p>
" );
}

routeNotificationForEmail

You can let the Notifiable instance define how to send the Email Notification by adding a routeNotificationForEmail method.
component accessors="true" {
property name="email";
public string function routeNotificationForEmail() {
return getEmail();
}
}