forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.67k stars 337 forks source link

Send mails using nodemailer transporter #268

Closed kodelio closed 6 years ago

kodelio commented 6 years ago

Hi :)

I'm trying to send emails with my transporter. I have errors like "No recipients defined". What I wrong ? Thank you.

let transporter = nodemailer.createTransport(transporterConfig);

const email = new EmailTemplate({
    views: {
        root: typeMail
    },
    message: {
        from: mailOptions.from,
        to: mailOptions.to,
        subject: mailOptions.subject
    },
    transport: transporter,
    config: {
        transport: transporter
    }
});

email.send({
    locals: {
        data
    }
}).then(console.log).catch(console.error);
borisyordanov commented 6 years ago

@kokno Did you find out what the problem was, can you share that with us?

kodelio commented 6 years ago

Hi, it was a problem with the mailOptions variable and an incorrect binding of parameters.