Skip to content

Add docs for non SES, non Mailgun SMTP settings #16

@damusix

Description

@damusix

In reference to:

Docs/config.mdx

Lines 217 to 352 in 45ae446

### Mail
*(Required in production)*
The most important piece of configuration once the installation is complete is to set up mail. Configuring mail allows Ghost to send transactional emails such as user invitations, password resets, member signups, and member login links. With the help of a bulk email service, you can also configure Ghost to send newsletters to members.
Ghost uses [Nodemailer](https://github.com/nodemailer/nodemailer/) under the hood, and tries to use the direct mail service if available.
We recommend ensuring transactional emails are functional before moving on to bulk mail configuration.
#### Configuring with Mailgun
[Mailgun](https://www.mailgun.com/) is a service for sending emails and provides more than adequate resources to send bulk emails at a reasonable price. Find out more about [using Mailgun with Ghost here](/faq/mailgun-newsletters/).
Mailgun allows you to use your own domain for sending transactional emails. Otherwise, you can use a subdomain that Mailgun provides you with (also known as the sandbox domain, limited to 300 emails per day). You can change this at any time.
Mailgun is an optional service for sending transactional emails, but it is required for bulk mail — [read more](/faq/mailgun-newsletters/).
#### Create a Mailgun account
Once your site is fully set up [create a Mailgun account](https://signup.mailgun.com/). After your account is verified navigate to **Domain settings** under **Sending** in the Mailgun admin. There you’ll find your SMTP credentials.
<Frame>
<img src="/images/0c2ceac3-mailgun-smtp_hub94c62b257175129863d85e1a9325a52_48235_866x0_resize_q100_h2_box_3.webp" />
</Frame>
In addition to this information, you’ll need the password, which can be obtained by clicking the **Reset Password** button. Keep these details for future reference.
Mailgun provides options for using their own subdomains for sending emails, as well as custom domains for a [competitive price](/faq/mailgun-newsletters/#did-you-know-mailgun-doesn-t-have-free-accounts-anymore).
#### Add credentials to `config.production.json`
Open your production config file in any code editor and add the following mail configuration, making sure to update the values to the same credentials shown in your own Mailgun SMTP settings:
```json
// config.production.json
"mail": {
"transport": "SMTP",
"options": {
"service": "Mailgun",
"auth": {
"user": "postmaster@example.mailgun.org",
"pass": "1234567890"
}
}
},
```
Once you are finished, hit save and then run `ghost restart` for your changes to take effect. These same credentials can be used for development environments, by adding them to the `config.development.json` file.
Mailgun provides a sandbox mode, which restricts emails to authorized recipients. Once sandbox mode is enabled, add and verify the email addresses you want to send emails to prior to testing.
#### Secure connection
Depending on your Mailgun settings you may want to force a secure SMTP connection. Update your `config.production.json` with the following for a secure connection:
```json
// config.production.json
"mail": {
"transport": "SMTP",
"options": {
"service": "Mailgun",
"host": "smtp.mailgun.org",
"port": 465,
"secure": true,
"auth": {
"user": "postmaster@example.mailgun.org",
"pass": "1234567890"
}
}
},
```
As always, hit save and run `ghost restart` for your changes to take effect.
#### Amazon SES
It’s also possible to use [Amazon Simple Email Service](https://aws.amazon.com/ses/). Use the SMTP username and password given when signing up and configure your `config.[env].json` file as follows:
```json
"mail": {
"transport": "SMTP",
"options": {
"host": "YOUR-SES-SERVER-NAME",
"port": 465,
"service": "SES",
"auth": {
"user": "YOUR-SES-SMTP-ACCESS-KEY-ID",
"pass": "YOUR-SES-SMTP-SECRET-ACCESS-KEY"
}
}
}
```
#### Email addresses
**Default email address**
Ghost uses the value set in `mail.from` as the default email address:
```json
"mail": {
"from": "support@example.com",
}
```
A custom name can also optionally be provided:
```json
"mail": {
"from": "'Acme Support' <support@example.com>",
}
```
Try to use a real, working email address - as this greatly improves delivery rates for important emails sent by Ghost (Like password reset requests and user invitations). If you have a company support email address, this is a good place to use it.
**Support email address**
When setting a custom support email address via **Settings****Portal settings****Account page**, you override the default email address for member communications like sign-in/sign-up emails and member notifications.
**Newsletter addresses**
It’s also possible to set a separate sender and reply-to address per newsletter, which will be used instead of the default. Configure these addresses via **Settings****Newsletters**.
The table below shows which email is used based on email type. In the table, if an address is not, it falls back to the next available address until reaching the default.
| Email type | Address used | Examples |
| -------------------- | ------------------- | ---------------------------------- |
| Member notifications | Support, Default | Signup/sign links, comment replies |
| Newsletters | Newsletter, Default | Configurable per newsletter |
| Staff notifications | Default | Recommendations, signups |
Irrespective of how you configure email addresses, maximize deliverability by ensuring DKIM, SPF, and DMARC records are configured for your sending domains.

I use MailerSend in particular for sending my emails. I have to configure Ghost using SMTP, and I self-host on Digital Ocean.
DO blocks ports 465, 587, and 25 by default— and so does Linode and some other cloud providers— but MailerSend also uses Port 2525 as a backup.

For custom email ports, it's not going to STARTTLS automatically, because t's non-standard. In these cases, you need to explicitly tell Nodemailer to not use SSL connection (secure: true), and instead require TLS, and the TLS version number. Here's a sample config:

mail__transport=SMTP
mail__from="'Fulanito Lopez' <noreply@menganito.com>"
mail__options__host=smtp.mailersend.net
mail__options__port=2525
mail__options__secure=false.             # critical: STARTTLS, not SSL-on-connect—must be false
mail__options__requireTLS=true           # insist on STARTTLS
mail__options__tls__minVersion=TLSv1.2   # MailerSend requires TLSv1.2
mail__options__auth__user=YOUR_SMTP_USER
mail__options__auth__pass=YOUR_SMTP_PASS
{
  "mail": {
    "from": "'Fulanito Lopez' <noreply@menganito.com>",
    "transport": "SMTP",
    "options": {
      "host": "smtp.mailersend.net",
      "port": 2525,
      "secure": false,
      "requireTLS": true,
      "tls": {
        "minVersion": "TLSv1.2"
      },
      "auth": {
        "user": "YOUR_SMTP_USER",
        "pass": "YOUR_SMTP_PASS"
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions