"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: '"Annuaire des associations - Espace Condorcet Centre Social" ', to: 'spamfree@matthieubessat.fr', subject: 'Votre lien secret pour modifier votre association - Annuaire des associations', 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: // 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);