The "email" app has a service that provides a way of sending e-mails using nodemailer.
When the "email" service is loaded, it creates a nodemailer instance based on configuration. If configured to send mail, a real nodemailer SMTP transport will be created. If not, the e-mail that would be send will be printed to the console.
App.$email.sendMail({
from: "webmaster@example.com",
to: "recipient@example.com",
subject: "Hello",
text: "Hi!
});
The arguments passed to sendMail on the "email" service are directly passed
to the sendMail method of nodemailer transport. The "email" service first
checks if it should send e-mail, and if not, prints the would-be e-mail to
the console (for development purposes).
The default configuration of the "email" app is this:
module.exports = {
sendMail: false,
smtpHost: process.env.SMTP_HOST || 'localhost',
smtpPort: process.env.SMTP_PORT || 465,
smtpIsSecure: true,
smtpUser: process.env.SMTP_USER || 'user',
smtpPassword: process.env.SMTP_PASSWORD || 'password'
};
The value of sendMail is used to determine how nodemailer should be
constructed, and whether or not to attempt to send mail over SMTP. The ohter
values are used to construct a nodemailer transport (if sendMail is true).
You can publish the configuration for the "email" app to config/email.js
using the following command:
node . publish --config email