How to setup SMTP email on Ghost

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to configure SMTP on Ghost.

Ghost is a content management system that you can use to manage content on your blog. In order to send emails from Ghost, one needs to configure emails manually on the config.production.json.

However, the email feature it's not only necessary for sending newsletters, but it's also necessary for people to comment on your blog, because one needs to sign up first on your blog using an email and then they can comment. So to make sure that people can subscribe to your newsletter and comment on your blog, you need to setup smtp.

Simply follow the steps in this tutorial, and get your email configured on your blog.

Step 1 - Create a Mailersend account

There are a lot of different email providers that you can use. However, in this tutorial we are going to use mailersend, as this is the email provider we also use. You can send up to 3000 emails on the free plan.

Sign up on Mailersend

Step 2 - Add domain on Mailersend

To add a domain on mailersend, you need to click to Email > Domain > and click to the "Add domain" button as shown in the image below

Next, setup dns records, simply follow the instructions you see on the page , on this step you basically have to add each dns record on your hosting/domain provider. Once you are done, click the switch button "I have added DNS records" and then click to "Re-check now" to verify the dns records.

💡

Note: This process may take up to 24 hours. Also, they send you an email once your domain has been verified, so keep an eye on your email.

Step 3 - Configure email

To configure email, you need to login to your server first, using the same user account that you used when installed ghost.

su user

For example, our user is called ghost_user, so to login as ghost_user simply replace user with ghost_user as shown in the image below

Simply open config.production.json file with a text editor

sudo nano config.production.json

💡

Note: config.production.json file is very important, as it's the file that contains the configuration for you ghost blog, if this file is not configured correctly your blog will not work. To avoid this, you can copy the current config before making changes on it, so if something happens you can use the old config.

Copy config.production.json into `config.json`

sudo cp config.production.json config.json

Next, verify that the config.json got created, using the ls command

ls

Now copy the email config below into the config.production.json file

  "mail": {
    "service": "emailprovider",
    "from": "email@email",
    "transport": "SMTP",
    "options": {
      "host": "smtp.server.com",
      "port": 587,
      "secureConnection": false,
      "auth": {
        "user": "user",
        "pass": "password"
      }
    }
  },

💡

Note: You can find SMTP details on SMTP section on Mailersend.

Once you are done with the configuration, save the config by pressing CTRL + X, then confirm by pressing Y key, and you should have now a configured email.

💡

Note: You need to restart your ghost blog once you configure the email. Make sure that the json file is valid before restarting your blog, to do this, you can copy the whole config on config.production.json into vscode, and see if the syntax is valid, proceed to restart your ghost blog if no issues found.

ghost restart

The config.production.json should look like this

{
  "url": "",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": ""
    }
  },
  "mail": {
    "service": "emailprovider",
    "from": "email@email",
    "transport": "SMTP",
    "options": {
      "host": "smtp.server.com",
      "port": 587,
      "secureConnection": false,
      "auth": {
        "user": "user",
        "pass": "password"
      }
    }
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "local",
  "paths": {
    "contentPath": ""
  }
}

Step 4 - Test email

Now you need to test if the emails are working correctly. Simply sign up or subscribe to your newsletter, and see if you receive an email.

If you don't receive emails, you can check logs to see if there's an issue.

1)Navigate to the folder where your ghost blog is installed

cd /var/www/ghost

replace: ghost with the name of your website/folder where your ghost is installed

2)And run the command below to check logs

ghost log

Alternatively, you can tail the log file in real time using the command below

ghost log -f

Conclusion

In this tutorial, you learned how to configure SMTP on Ghost, for sending outbound emails.