Mailgun config from env vars

I don’t think the config guide is up to date. This has settings for email but they aren’t reflected in the UI.

In Ghost 5 all you have are two boxes - domain and API key. How do you set these through env vars?

Ghost differentiates configuration and settings. Configuration comes from the config file (or env) and cannot be edited at runtime. Settings come from the database, and cannot be statically configured. Any setting that can be configured in Ghost Admin can be configured using the Ghost API, though there might be restrictions on if an API token can change it or a logged-in user can change it.

There’s no way to set this through configuration?

As far as I’m aware it’s not possible to configure the bulk email settings via the config file

That’s a bummer. I want to be able to bootstrap ghost instances I deploy to kubernetes. Using the API is a bit of a circular dependency where I need to set up ghost but first I need to get an API key to set up ghost. :frowning:

Why is this preventing you from setting up Ghost? Transactional email is managed by the config so it shouldn’t prevent you from creating the first user.

I want to migrate and/or deploy instances without having to cut and paste things into the UI. Ghost “out of the box”, since I can’t set this up via config, has to be manually configured. That’s a bummer.

@Kevin helped me out with this in another thread.
It doesn’t seem to be working. The Mailgun Settings are still visible on my admin and the values are blank.

My env vars (k8s pod via terraform) look like this:

    logging__transports = "[\"stdout\"]"
    database__client    = "mysql"

    bulkemail__mailgun__mailgun_api_key = <my api key>
    bulkemail__mailgun__mailgun_domain          = <my domain>
    bulkemail__mailgun__mailgun_base_url        = ""

    mail__transport              = "SMTP"
    mail__options__service       = "Mailgun"
    mail__options__host          = ""
    mail__options__port          = 465

You’ve used bulkemail not bulkEmail - casing is important

For an envar? Interesting.

I tried that and get an “invalid url” now. :thinking:

Yeah this just doesn’t seem to work. If I configure it through the UI it works but if I put the exact same settings in bulkEmail__mailgun__mailgun_base_url, etc, I get an invalid URL error.

Sorry, I think I misread the code where there’s a difference between settings and config. Can you try without the extra mailgun and camelCase naming throughout, e.g.:

bulkEmail__mailgun__apiKey         = <my api key>
bulkEmail__mailgun__domain         = <my domain>
bulkEmail__mailgun__baseUrl        = ""

Thanks for double checking that. Seems to work.
I tested locally with this:

logging__level=DEBUG \
bulkEmail__mailgun__apiKey=<mykey> \
bulkEmail__mailgun__domain=<mydomain> \
bulkEmail__mailgun__baseUrl="" \
node current/index.js

And I got a shiny email. Thanks so much.