Getting Ghost to Work with Brevo

After being banned from Mailgun and AWS SES trying to get my Ghost blog to send emails - I just ended up developing my own solution and create a repo that uses Brevo API calls to deliver emails.

Getting Ghost to Work with Brevo

I recently moved from Substack to Ghost, and hit some major issues getting my emails to work. This bricked new subscriptions, logins, and the delivery of new newsletter posts to my existing subscribers.

I decided to document what I modified, fixed, or changed to get things working, and my battle with Mailgun and my switch to Amazon SES.

Moving from Substack to Ghost (And my battle with Mailgun)
Some of the hurdles moving to ghost. Tips on Mailgun, fixing ActivityPub, and bypassing Mailgun with AWS SES.

Table of Contents

(browser only, email clients won't load it)

Well... Amazon SES denied my requests to the production SES environment. Before I could send an email out. I put in a support ticket and outlined everything in detail, what I was using, how I was using it, explained how I was using SQS to properly manage email queues, dropped so much. And denied.

So I started looking for alternatives again. This time, landing on a project to handle sending newsletters using Brevo called Ghosler.

GitHub - ItzNotABug/ghosler: Send newsletter emails to your Ghost CMS subscribers & members, using your own email credentials!
Send newsletter emails to your Ghost CMS subscribers & members, using your own email credentials! - ItzNotABug/ghosler

This would let me bypass the need for Mailgun by standing up a server that intercepts requests made to Mailgun and instead sends them to a different SMTP server.

But, because my infrastructure runs on DigitalOcean, I can't use SMTP. Well, I can set things up to send on weird ports like 2525, but there is a chance that DigitalOcean could just nuke my droplet after sending thousands of emails for my newsletter. It's a less-than-opportune situation.

  1. I can't use SMTP outbound because DigitalOcean blocks the standard SMTP ports.
  2. Not all email providers will support ports like 2525 (like ProtonMail).
  3. This doesn't cover transactional emails that still require SMTP.

Making my own solution

After getting extremely dejected and spending this past week frantically trying to get my blog up and running again, I decided to build off Ghosler and add some functionality to get things working.

Some major criteria this had to hit:

  1. I needed to send emails without using SMTP. An API would be better because it would use HTTPS instead of SMTP.
  2. It had to handle both transactional emails (subscription and login requests) and newsletter emails.
  3. The project could not modify the actual source code of Ghost (I didn't want to break it).

I saw Brevo recommended a lot on the Ghost forms, and they had an API, didn't automatically sandbox you or require you to request access to a production account, and were pretty well priced for emailing at volume.

So I made this!

GitHub - hydroponictrash/ghost-brevo-controller: Send Ghost CMS emails via Brevo HTTP API instead of SMTP. Bypasses VPS port blocks on DigitalOcean and similar providers.
Send Ghost CMS emails via Brevo HTTP API instead of SMTP. Bypasses VPS port blocks on DigitalOcean and similar providers. - hydroponictrash/ghost-brevo-controller

It basically extends Ghosler to work for both newsletter and transactional emails, sending them through Brevo's email API without using SMTP, while still delivering them to inboxes.

For transactional emails, there is a local SMTP server that gets plugged into Ghost's production config, and tells it to send emails to your local SMTP server. The SMTP messages are turned into API calls for Brevo's API.

For newsletter emails, it works like Ghosler, but it instead takes the requests and sends them via Brevo's API instead of SMTP.

Using the project

All of the configuration is automated. You run three scripts, answer their questions, and then you get all of your email stuff for Ghost using Brevo's API.

  1. Get your custom domain, make an account for Brevo, and get the required DNS records verified.
  2. In Brevo settings, go to >> Settings>> Senders, domains, IPs
  3. Add a sender for your transactional emails (like [email protected])
  4. Add a sender for your newsletters (like [email protected])
  5. Set up a webhook in the Ghost admin portal to tell Ghost where to send the emails.
  6. Follow the quick start guide and run install.sh and configure.sh.
  7. You are ready to test and send.

This is V1; there are some things I want to update

For now, things are going smooth. But there is one major thing I don't like:

Newsletters will go out to every subscriber, regardless on if you tell Ghost to send it to a smaller group.

You can get around this by making different newsletters in Ghost, but I'm kinda lazy and don't need to do that because every one of my subscribers gets my posts for free - regardless on if they are paid subscribers.

But if you have stuff paywalled, this might be an issue.

In later versions, I want to fix that and have it follow the member tags that Ghost uses, so you can send posts to who you want to. Right now, it's pretty manual when it comes to breaking up user groups.