# Make onboarding emails also work via API (not only SMTP)

**URL:** <https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426>\
**Category:** Self-hosting\
**Created:** [March 28, 2025, 7:36pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426 "2025-03-28T19:36:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nodepond](https://avatars.discourse-cdn.com/v4/letter/n/5f9b8f/32.png) [@Nodepond](https://forum.ghost.org/u/Nodepond)\
**Post date:** [March 28, 2025, 7:36pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/1 "2025-03-28T19:36:35Z")

</div>

The following problem:

I had some issues setting up SMTP for Digital Ocean. And also other hosters, since there seems to be a tendency towards “we will not allow SMTP traffic” for a good reason. Please also refer to this thread: [Use Mailgun API, instead of SMTP for onboarding-emails?](https://forum.ghost.org/t/use-mailgun-api-instead-of-smtp-for-onboarding-emails/56417)

The idea here is now: Why not make ghost available to use API-calls, like the one we have with mailgun, to get the onboarding emails gone right.

Right now I can live with the “workarounds”, like using ports not suitable for SMTP. But this might be just a matter of time, since ports getting blocked.

Solution:

Make an API option for onboaring-emails as well. (like mailgun API, that is already heavily promoted).

I would assume, that this would bring a so much more flexibility to open-source hosting.

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [March 28, 2025, 8:55pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/2 "2025-03-28T20:55:34Z")

</div>

Ghost should support using Mailgun via API for transactional email. Can you try the configuration from this portion of the docs?

> **[Configuration - Adapt your publication to suit your needs](https://ghost.org/docs/config/#add-credentials-to-configproductionjson)**
>
> Find out how to configure your Ghost publication or override Ghost's default behaviour with robust config options, including mail, storage, scheduling and more!

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [March 28, 2025, 9:37pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/3 "2025-03-28T21:37:53Z")

</div>

Vikas, the docs don’t show an example with Mailgun API, only SMTP. Might be a docs problem, though!

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [March 28, 2025, 11:12pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/4 "2025-03-28T23:12:53Z")

</div>

heh my bad, I saw the section and ~~walked~~ read right past it 🙃

Reading the [wrapper code](https://github.com/TryGhost/framework/blob/81ac08a6878c0f1507c3e59b79ff30ba7f58dff2/packages/nodemailer/lib/nodemailer.js) and [nodemailer-mailgun-transport docs](https://www.npmjs.com/package/nodemailer-mailgun-transport#mailgun-regions), I think something like this might work:

```auto
"mail": {
    "transport": "mailgun",
    "options": {
        "host": "<>",
        "auth": {
            "api_key": "<>",
            "domain": "<>"
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Nodepond](https://avatars.discourse-cdn.com/v4/letter/n/5f9b8f/32.png) [@Nodepond](https://forum.ghost.org/u/Nodepond)\
**Post date:** [March 30, 2025, 12:05pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/5 "2025-03-30T12:05:09Z")

</div>

Amazing!

It absolutely works! Would be great, to have this mentioned in the docs. But at least we have now this searchable in the forums.

Thanks again!

---

<div class="post-metadata">

**Author:** ![adventgineering](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/adventgineering/32/18252_2.png) [@adventgineering](https://forum.ghost.org/u/adventgineering)\
**Post date:** [May 29, 2025, 4:33am UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/6 "2025-05-29T04:33:12Z")

</div>

Seconding this update to the docs when possible. I spent 1-2 days just to discover this as Digital Ocean has now blocked sending with SMTP. The workaround with port 2525 is working but not sure for how long. My suggestion is to please mention this somewhere in the docs that it could be caused by **Digital Ocean’s blocking** as I have 5 separate websites running on ghost hosted by digital ocean that I now need to reconfigure.

Thank you.

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [June 9, 2025, 11:36pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/7 "2025-06-09T23:36:02Z")

</div>

Just adding a full config example here for anyone who needs it.

```auto
  "mail": {
    "transport": "mailgun",
    "from": "an-email-address-that-i-confirmed-with-mailgun@mydomain.tld",
    "options": {
      "auth": {
        "api_key": "my-big-long-api-key-string-from-mailgun",
        "domain": "mg.mydomain.tld"
      },
      "host": "api.mailgun.net"
    }
  },

```

This is what I’ve got live on my server on 5.121.

---

<div class="post-metadata">

**Author:** ![Geb05](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/geb05/32/36903_2.png) [@Geb05](https://forum.ghost.org/u/Geb05)\
**Post date:** [July 25, 2025, 3:08am UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/8 "2025-07-25T03:08:30Z")

</div>

I’m also stuck in the Digitalocean smtp issue, but using this is giving me an “invalid Mail Transport” messge saying that the mail.transport key value of mailgun isnt valid. Any idea what the issue might be?

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [July 25, 2025, 6:21am UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/9 "2025-07-25T06:21:44Z")

</div>

Can you share your redacted config?

---

<div class="post-metadata">

**Author:** ![carolina](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/carolina/32/36963_2.png) [@carolina](https://forum.ghost.org/u/carolina)\
**Post date:** [July 26, 2025, 1:57pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/10 "2025-07-26T13:57:26Z")

</div>

Yeah, I’ve been able to reproduce this.

Setup works fine, but when you run `ghost start` or `ghost doctor`, the CLI flags the value `mail.transport` when set to `"mailgun"` as invalid. But, the workaround I’ve found is that when running `ghost restart` the unintended behaviour does not occurr.

Going to make an issue on GitHub, initially thought this was some error on my end, but it seems clear that this may be unintended behaviour.

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [July 26, 2025, 3:12pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/11 "2025-07-26T15:12:36Z")

</div>

I can confirm - I also need to `ghost restart`. This is probably a Ghost CLI issue, not main Ghost. (There’s a separate repo.) @acburdine may be interested, too! (Hi Austin!)

---

<div class="post-metadata">

**Author:** ![acburdine](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/acburdine/32/4825_2.png) [@acburdine](https://forum.ghost.org/u/acburdine)\
**Post date:** [July 26, 2025, 3:27pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/12 "2025-07-26T15:27:38Z")

</div>

Yeah, looks like this is a bug on the CLI side - will get it fixed here in the next few days 👍🏻

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [July 26, 2025, 6:32pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/13 "2025-07-26T18:32:20Z")

</div>

I’m relocating the post to self hosting, so that we can discuss at full speed if wanted :)

---

<div class="post-metadata">

**Author:** ![acburdine](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/acburdine/32/4825_2.png) [@acburdine](https://forum.ghost.org/u/acburdine)\
**Post date:** [July 28, 2025, 1:43am UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/14 "2025-07-28T01:43:24Z")

</div>

Hey folks - a fix for the `ghost doctor`/`ghost start` issue was released in Ghost-CLI 1.28.1 - let us know if you see any more issues with it 😃

---

<div class="post-metadata">

**Author:** ![fieldnoise](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fieldnoise/32/32905_2.png) [@fieldnoise](https://forum.ghost.org/u/fieldnoise)\
**Post date:** [August 12, 2025, 1:55am UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/15 "2025-08-12T01:55:30Z")

</div>

Has anyone tested out how/if this might be possible with the new v6 docker `.env` file?

---

<div class="post-metadata">

**Author:** ![bjokib](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/bjokib/32/37351_2.png) [@bjokib](https://forum.ghost.org/u/bjokib)\
**Post date:** [August 14, 2025, 11:39am UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/16 "2025-08-14T11:39:08Z")

</div>

I have the same problem. I can send e-mails/newsletters fine via the API setup. But I am not able to get newsletter signups working. It wont send the e-mail.

How should the e-mail section in the .env file be so it is using the API instead? I am using the docker installation method.

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [August 14, 2025, 12:17pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/17 "2025-08-14T12:17:53Z")

</div>

> [@Cathy\_Sarisky](#):
>
> ```auto
> "mail": {
> "transport": "mailgun",
> "from": "an-email-address-that-i-confirmed-with-mailgun@mydomain.tld",
> "options": {
> 
> ```

Generically, the env variables for Ghost in docker look like mail\_\_transport, mail\_\_from, mail\_\_options\_\_auth\_\_api\_key, etc. Use double \_ between nested values in the json.

---

<div class="post-metadata">

**Author:** ![bjokib](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/bjokib/32/37351_2.png) [@bjokib](https://forum.ghost.org/u/bjokib)\
**Post date:** [August 14, 2025, 1:29pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/18 "2025-08-14T13:29:04Z")

</div>

Thank you for answering I appreciate it.

I have added this in the .env file, but it doesn’t seem to work. (XXXX Is for privacy)

```json
mail__transport=mailgun
mail__host=api.mailgun.net
mail__from=bxxxxx@gmail.com
mail __options__ auth__api_key=3xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1610-f87df25e
mail __options__ auth__domain=sandbox5xxxxxxxxxxxxxxxxxxxx4.mailgun.org

```

Any ideas, or have I done something wrong here?

If I try to see in the docker logs I get:

```bash
[2025-08-14 13:20:15] INFO ActivityPub webhooks in correct state
[2025-08-14 13:20:15] INFO URL Service ready in 1267ms
[2025-08-14 13:20:25] INFO "GET /members/api/integrity-token/" 200 15ms
[2025-08-14 13:20:25] ERROR Failed to send email. Reason: Forbidden.

Failed to send email. Reason: Forbidden.

"Please see https://ghost.org/docs/config/#mail for instructions on configuring email."

Error ID:
    70989c60-7911-11f0-a78b-4bb82bcc182a

```

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [August 14, 2025, 1:33pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/19 "2025-08-14T13:33:05Z")

</div>

Getting a fresh api key from mailgun may be helpful. You might also check Mailgun for any error logs.

---

<div class="post-metadata">

**Author:** ![bjokib](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/bjokib/32/37351_2.png) [@bjokib](https://forum.ghost.org/u/bjokib)\
**Post date:** [August 14, 2025, 1:53pm UTC](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426/20 "2025-08-14T13:53:12Z")

</div>

Yeah, I can see it is getting rejected in Mailgun logs. Not sure why, apparently it has to be able to send some data to mailgun.

```auto

```

[Next page](https://forum.ghost.org/t/make-onboarding-emails-also-work-via-api-not-only-smtp/56426.md?page=2)
