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.66k stars 339 forks source link

Preview shown but email not being sent #402

Closed martinpiria closed 4 years ago

martinpiria commented 4 years ago

I configured it the following way:

const email = new Email({
    message: {  
        from: 'donotreply@edwardshavens.com'
    },
    options: {
        send: true
    },
    transport: {
        jsonTransport: true
    }
});

The preview is being shown but the email not being sent to the mailbox, is there any configurations missing from the email server's side?

niftylettuce commented 4 years ago

send should be top level option, not nested in an object, see https://github.com/forwardemail/email-templates#basic

martinpiria commented 4 years ago

Changed it but still doesn't work, the receiving email box doesn't get the message? Feels like I'm missing configuration from the sending email server

niftylettuce commented 4 years ago

you have to configure a transport, see nodemailer docs

ohabash commented 2 years ago

I can see how to use nodemailer but how do i use that with email-templates?

Is this it?

let transporter = nodemailer.createTransport({
    host: "smtp.ethereal.email",
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
      user: testAccount.user, // generated ethereal user
      pass: testAccount.pass, // generated ethereal password
    },
  });

new Email({
      message: { from: 'asd@dasda.com' },
      send: true,
      views: { root },
      transport: transporter,
    });
ohabash commented 2 years ago

Thank you!

This is how we did it for 365.

get transport() {
    return nodemailer.createTransport({
      service: 'Outlook365',
      auth: {
        user: "FROM@DOMAIN.AI",
        pass: "pass",
      },
    });
  }

  async init() {
    const root = path.join(__dirname, 'emails');
    this.Email = new Email({
      message: { from: this.from },
      send: true,
      views: { root },
      transport: this.transport,
    });
    return this;
    // this.repsonse = await this.send(); // DEV ONLY
  }

plus we had to do some configs in 365