Ghost icon indicating copy to clipboard operation
Ghost copied to clipboard

Support for REST API based email delivery

Open mfkuntz opened this issue 9 years ago • 6 comments

Issue Summary

Ghost can currently send email over SMTP using nodemailer. Adding support to enable sending over API would:

  1. Conform to recommended patterns from major mail platforms. ex Mailgun

  2. Many hosting providers block SMTP ports by default. There are workarounds, like setting up postfix and proxying on a seperate port, but they are not clean. ex Google Cloud

Drawbacks

Mail providers don't have a standard API, and there will need to be a custom implementation for each. The official docs reference Mailgun (they seem to be a partner or recommended vendor) so (in my opinion) that would be a good starting point.

Requirements

  1. Configuration specification and format. In my testing, there are a couple of standard fields across providers and it should be fairly simple to create a mapping.

  2. Documentation updates explaining the new options and their benefits.

  3. Pretty error codes around trying to specify a provider that doesn't exist.

  4. Tests


I wrote what I imagine a Mailgun implementation of this would look like, targeted at the stable branch (since that is where I needed it). If this sounds like a good fit for an upstream merge, I can take care of 2 and 3 and submit a pull request.

mfkuntz avatar Feb 01 '17 03:02 mfkuntz

Potential config format (Req#1)

mail: {
    transport: 'API',
    options: {
        service: 'mailgun', // used to lookup a specific implementation
        host: 'mail.example.com', // used if there are multiple domains attached to the mailgun account
        auth: {
            token: 'nope'
        }
    }
},

mfkuntz avatar Feb 01 '17 03:02 mfkuntz

Hey @mfkuntz 👋

Thanks for your suggestion and interest in working on this.

Adding new adapters for sending mails requires Ghost to support it. Right now it's hardcoded to use the nodemailer integration.

We already have an issue to make this possible, see https://github.com/TryGhost/Ghost/issues/7687. Helping us making mail as adapter is very welcome 👋

As soon as Ghost supports installing a different mail adapter, the community is able to implement any mail integration. We already support adapters for storages and scheduling.

BTW: Last year we already started with the integration of the Mailgun API as part of our existing subscriber feature, which is still in beta.

kirrg001 avatar Feb 01 '17 09:02 kirrg001

nodemailer already supports different transports (e.g. this mailgun api transport) - if self-hosting it may be possible to install this node module and pass the required config params

kevinansfield avatar Feb 01 '17 11:02 kevinansfield

@kevinansfield true, but therefor we need to upgrade nodemailer, see https://github.com/TryGhost/Ghost/issues/4125

kirrg001 avatar Feb 01 '17 12:02 kirrg001

@kirrg001 - Thanks for the adapter link, I will take a look there.

@kevinansfield - I did take a look at that, but decided not to use it since it seems like adding a dependency directly on a mailgun package is a little weird to put in the core if most people wont use it. Also, I noticed that mailgun doesn't have an official node library, probably because their rest API is so nice.

mfkuntz avatar Feb 01 '17 15:02 mfkuntz

@kirrg001 Any update on this? In our case, there is no option but to use Mailgun API key as our client cannot provide credentials for SMTP.

evenfrost avatar Aug 22 '17 11:08 evenfrost