How to add SMTP (mail) configuration?

Everything that’s in the config file can be set via env vars and vice-versa. You should choose one method that suits how you want to set up your container rather than defining things twice and adding confusion over what is set where.

If you get rid of the config file you can keep your docker config and add the mail options, e.g.

    environment:
      # see https://ghost.org/docs/config/#configuration-options
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: example
      database__connection__database: ghost
      # this url value is just an example, and is likely wrong for your environment!
      url: http://localhost:8080
      # contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)
      #NODE_ENV: development
      mail__from: "'MyDomain' <postmaster@mail.mydomain.com>"
      mail__transport: "SMTP"
      mail__options__host: "smtp.mailgun.org"
      mail__options__port: 465
      ...

More info on config can be found in the documentation Configuration - Adapt your publication to suit your needs

1 Like