The apostrophe-email
module implements the email
method that is available to all modules. Please see the [https://apostrophecms.org/docs/tutorials/howtos/email.html](apostrophecms email HOWTO) for more information about that.
This module is focused on one job - delivering email - and doesn't specifically have anything to do with account creation. And while the apostrophe-login module has a password reset feature that sends email, it doesn't currently send email on account creation. However, you can do that yourself by writing an afterInsert
method for the apostrophe-login
module at project level in your own code:
// in lib/modules/apostrophe-users/index.js
module.exports = {
email: {
// default "from" address for this module
from: 'example@example.com'
},
construct: function(self, options) {
self.afterInsert = function(req, piece, options, callback) {
return self.email(req, 'emailInserted', {
piece: piece
}, {
// can also specify from and other
// valid properties for nodemailer messages here
to: piece.email,
subject: 'A new account was created'
},
callback
);
};
}
};
This code is lifted almost without modification from an example in the email tutorial for sending email when a different kind of piece is inserted. That works because users are pieces too.
Note that the password is not exposed here. For security reasons it is deleted from the object pretty quickly. You should never email a password.