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

Nodemailer templating error: EmailTemplate is not a constructor #294

Closed luisk182 closed 6 years ago

luisk182 commented 6 years ago

Hi, I just installed the new version of email-templates and Im getting this error in console EmailTemplate is not a constructor

Im following this example https://community.nodemailer.com/2-0-0-beta/templating/

I have this

const EmailTemplate = require('email-templates').EmailTemplate
        const nodemailer = require('nodemailer')
              let transporter = nodemailer.createTransport({
                host: '00.3.6.3',
                port: 25,
                auth: {
                  user: 'noreply@mimail.com',
                  pass: 'noreply01'
                },
                debug: true, // include SMTP traffic in the logs
                logger: true
              })
          let sendPwdReminder = transporter.templateSender(new EmailTemplate('static/mailTemplate'), {
              from: 'sender@example.com',
          })
          sendPwdReminder({
              to: 'luis_ledezma@mimail.com',
              subject: 'Password reminder'
          }, {
              username: 'Node Mailer',
              password: '!"\'<>&some-thing'
          }, function(err, info){
              if(err){
                 console.log('Error');
              }else{
                  console.log('Password reminder sent');
              }
          })
niftylettuce commented 6 years ago

Hi @luisk182 - those docs are outdated on the nodemailer website (that's for an old version).

Please see our README with usage examples and an upgrade guide here https://github.com/niftylettuce/email-templates#email-templates.

If you have further issues please open a new issue. Thanks!