40 lines
No EOL
1.6 KiB
JavaScript
40 lines
No EOL
1.6 KiB
JavaScript
"use strict";
|
|
const nodemailer = require("nodemailer");
|
|
|
|
// async..await is not allowed in global scope, must use a wrapper
|
|
async function main() {
|
|
// Generate test SMTP service account from ethereal.email
|
|
// Only needed if you don't have a real mail account for testing
|
|
//let testAccount = await nodemailer.createTestAccount();
|
|
|
|
// create reusable transporter object using the default SMTP transport
|
|
let transporter = nodemailer.createTransport({
|
|
host: 'smtp.mailgun.org',
|
|
port: 587,
|
|
secure: false,
|
|
auth: {
|
|
user: 'hello@sandboxeb2300b9439e4fe7bd2cca8f52ac7bd6.mailgun.org',
|
|
pass: 'b69383e5abcfc41014549be7d6b798bc-87c34c41-c9e7e87c'
|
|
}
|
|
});
|
|
|
|
// send mail with defined transport object
|
|
let info = await transporter.sendMail({
|
|
from: '"Forum des associations - Espace Condorcet Centre Social" <ne-pas-repondre@espacecondorcet.org>',
|
|
to: 'spamfree@matthieubessat.fr',
|
|
subject: 'Votre lien secret pour modifier votre association - Forum des associations 2020',
|
|
text: `Bonjour gérant de l'association nommée "We Robot's" Voici votre clée: P0118KUHD8`,
|
|
html: `Bonjour gérant de l'association nommée "We Robot's" \n` +
|
|
'\n' +
|
|
'Voici votre clée: P0118KUHD8\n'
|
|
});
|
|
|
|
console.log("Message sent: %s", info.messageId);
|
|
// Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
|
|
|
|
// Preview only available when sending through an Ethereal account
|
|
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
|
|
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
|
|
}
|
|
|
|
main().catch(console.error); |