menu

SiteGenesis / Server-side JS / Class: EmailModel

models/EmailModel~ EmailModel

new EmailModel(template, recipient)

Email helper providing enhanced email functionality

Parameters:
Name Type Description
template String

The template that is rendered and then sent as email.

recipient String

The email address where the text of the rendered template is sent.

Source:
Example
require('~/models/EmailModel').get('mail/resetpasswordemail', Customer.profile.email)
    .setSubject(dw.web.Resource.msg('email.passwordassistance', 'email', null)).send({
         Customer : Customer,
         ResetPasswordToken : ResetPasswordToken
    });

Extends

Methods

(static) sendMail(options) → {dw.system.Status}

Send an email

Parameters:
Name Type Description
options Object
Properties
Name Type Description
recipient String
template String
subject String
from String
context Object
Source:
Returns:

whether the mail was successfully queued (Status.OK) or not (Status.ERROR).

Type
dw.system.Status
Example
```
require('~/cartridge/scripts/models/EmailModel').sendMail({
    recipient: '[email protected]',
    template: 'mail/templatename',
    subject: 'Your order was placed successfully',
    from: '[email protected]',
    context: {
        Order: order
    }
});
````