Sending email is a pretty common operation, and it doesn't make sense
to duplicate that code.
The apostrophe-site module now provides an email transport via the
excellent nodemailer module.
It is available as site.mailer in app.js, and it is passed as the
"mailer" option to every module you configure in app.js.
For docs on usage, just check out nodemailer. (You do not have to
configure a transport - apostrophe-site passes you one; it makes sense
to share a transport object.)
* * *
On a related subject, you can now call self.render in a module with an
explicit file extension. This allows nunjucks to be used conveniently
to generate plaintext emails, as well as HTML emails.
This is available in modules subclassed derived from
apostrophe-snippets, and any other module that uses the assets mixin
(see assets.js in the apostrophe module).
And you can call self.renderPage as well. self.renderPage is only
meant for corner cases like login and password reset pages, little
interactions that need decoration with the outerLayout but have
nothing to do with Apostrophe's page tree at all. But it's super handy
for that situation:
return res.send(self.renderPage('reset', { message: 'whatever' }, 'anon'));
The "anon" argument means "nobody's logged in yet, so don't load the
stuff for logged-in users in the browser."
--
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com