adonisjs / mail

AdonisJS Email Provider
MIT License
106 stars 34 forks source link

SendGrid driver #19

Closed SAGV closed 6 years ago

SAGV commented 6 years ago

I'm very impressed with the framework and would like to thank @thetutlage and the others for the great job!

However, there is still a small detail missing — SendGrid driver for the mail so I think it deserves a separate issue.

P. S. See PR with the deprecated implementation https://github.com/adonisjs/adonis-mail/pull/1

thetutlage commented 6 years ago

Hi SendGrid doesn't offer any API which accepts the MIME formatted emails, that's why implementing a driver will be converting the underlying packet of Adonis mail to Sendgrid API fields.

This is 100% achievable, but more work for me to make sure.

  1. All fields from the mail MIME are converted 100% as per the sendgrid specifications.
  2. When they change the API, I have to make modifications too.

The mail driver is extendible, which means you can add your own drivers, within your app.

class SendGrid {
  setConfig (config) {
  }

  send (message) {
    // make sure to return promise
  }
}

ioc.extend('Adonis/Addons/Mail', 'sendgrid', function () {
  return new SendGrid()
})
SAGV commented 6 years ago

Indeed, no problem then.

Just in case if someone else needs it, here is a fork of deprecated implementation (#1 ): https://github.com/SAGV/adonis-mail/tree/feature/sendgrid-support-v4 which is adjusted for the latest adonis-mail version.

However, I didn't write tests so use on your own risk. Maybe one day I'll make a proper plugin out of it ;-)

thetutlage commented 6 years ago

👍