Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
// send mail with defined transport object
const info = await transporter.sendMail({
from: '"Fred Foo 👻" ', // sender address
to: 'bar@example.com, baz@example.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>' // html body
})
console.log('Message sent: %s', info.messageId)
// Message sent:
// Preview only available when sending through an Ethereal account
console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info))
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: '"Fred Foo 👻" ', // sender address
to: '2833324528@qq.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>' // html body
});
console.log('Message sent: %s', info.messageId);
// Message sent:
// Preview only available when sending through an Ethereal account
console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log({ error });
reject({
error
});
}
console.log("Message sent: %s", info.messageId);
// Preview only available when sending through an Ethereal account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
});
resolve({
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
reject({
message: "ERR",
error
});
}
console.log("Message sent: %s", info.messageId);
// Preview only available when sending through an Ethereal account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
});
resolve({
const { ENVIRONMENT, MAIL_FROM } = defaults;
const config = await MailerCredentials();
const transporter = nodemailer.createTransport(config);
const mailOptions = {
from: MAIL_FROM,
to, // list of receivers
subject, // Subject line
html: `${content}`, // html body
};
const info = await transporter.sendMail(mailOptions);
if (ENVIRONMENT !== 'production') {
logger.debug(`Message sent: ${info.messageId}`);
// Preview only available when sending through an Ethereal account
logger.debug(`Preview URL: ${nodemailer.getTestMessageUrl(info)}`);
}
}
const defaultSendEmailMethod = async function(template: string, variables: any, credentials: any) {
let transporter: any = await mailerInstance();
let compiled = handlebars.compile(template);
let resultTemplate = compiled(variables);
try {
let send = await transporter.sendMail({
from: credentials.from,
to: credentials.to,
html: resultTemplate,
subject: credentials.subject
});
console.log("Message sent: %s", send.messageId);
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(send));
return send;
} catch (e) {
console.log(`Failed sending email: ${e.message}`);
}
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
Logger.error(`error sending email: ${error}`);
return;
}
Logger.log(`Message sent: ${info.messageId}`);
const testMessageUrl = nodemailer.getTestMessageUrl(info);
Logger.log(`Preview URL: ${testMessageUrl}`);
});
}