0.8.2 • Published 2 months ago

sendjml v0.8.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

Sendjml

Send emails using mjml.

Design templates

In order to have a design structure, is necessary to set the folder containing the .mjml files.

{
  ...config,
  templates: `${__dirname}/design`,
}

The library will search for design templates, and overrides at the send time, always in this folder.

Using Sendgrid

We use Sendgrid mail library in case you have an API key already created.

yarn add sendjml @sendgrid/mail

Config using Sendgrid

const { sendgrid } = require('sendjml')

sendgrid.config({
  apiKey: process.env.SG_API_KEY,
  from: 'mymail@mymal.com',
  templates: `${__dirname}/design`,
})

Send using Sendgrid

const { sendgrid } = require('sendjml')
await sendgrid.send({
  to: 'anothermail@anothermail.com',
  subject: 'This is an email sent using Sendgrid',
  text: 'Sendgrid Lorem ipsum',
})

Using Gmail

In order to send emails using Gmail as SMTP, we use nodemailer. Sending this way is necessary to create an OAuth keys in a Google Cloud Platform application following this guide as an example.

yarn add sendjml nodemailer googleapis

Config using Gmail

In this case, the from field is not necessary because Gmail uses the one set as gmailUser.

const { gmail } = require('sendjml')

gmail.config({
  gmailUser: process.env.MAIL_USERNAME,
  oauthClientId: process.env.OAUTH_CLIENTID,
  oauthClientSecret: process.env.OAUTH_CLIENT_SECRET,
  oauthRefreshToken: process.env.OAUTH_REFRESH_TOKEN,
})

Send using Gmail

const { gmail } = require('sendjml')
await gmail.send({
  to: 'anothermail@anothermail.com',
  subject: 'This is an email sent using Sendgrid',
  text: 'Sendgrid Lorem ipsum',
})
0.8.2

2 months ago

0.8.1

6 months ago

0.8.0

1 year ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago