How to setup basic SMTP for Ghost
Tags: jamstack, ghost, node, writing
Published: 2022-03-22 21:53:45

## Disclaimer

I've just started to use Ghost as a platform for blogs. Before that, I've been using Word Press, in one of my previous jobs. In my opinion, Ghost might become as popular as WP, while being very clear and easy for content makers and developers same time.

What helped WP become so popular is the community, with many plugins, ready-to-go solutions, and how-tos, highlighting almost every moment and question that could arise around using this CMS.

I'm writing this to contribute to the public knowledge base of Ghost, simply because if I had this guide, this would save me several hours.

## About

This article covers the basic SMTP setup for self-deployed Ghost instances. If you want to use Ghost from the box without customisation and you are not ready to write code and edit JSON files, then I highly recommend you to use Ghost Pro: https://account.ghost.org/signup (I have no ref program or bonuses, this is just kind advice)

If you are trying to set up Ghost and don't understand how to deal with emails, this is for you 📧

## Ghost emails context

Ghost have great documentation and community. There are two cases with emails:

* Bulk — sending newsletters, you could pay for any dedicated service and use it
* Transactional — system stuff to work correctly with CMS

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9ngl9dudcurbpw9ggz5.png) _from https://ghost.org/docs/faq/mailgun-newsletters/_

Bulk usage is clear. You have to land your SMTP and the whole flow, or just pay for it and setup. But what if you need SMTP for Transactional emails only. Let's see what options you have:

* Setup SMTP server manually (spend time and/or money)
* Use one of the listed services (spend time and/or money)
* Gmail? What's up with Gmail?

## Solution

Almost everybody has Gmail, right? But a small amount of those knows, that it also includes free SMTP service, which is the same as other Google products: fast&reliable.

Everything you need is your email and dedicated app password (for security reasons).

🗝 To generate _this password_:

1. Go to https://myaccount.google.com/apppasswords
2. Enter your regular password from your Google account (this is security settings)
3. Select app, choose Other, and put the name (i.e SMTP)
4. Now copy your password and write it down (you will have no chance to see it for the second time here)

> For Ghost setup, I was using DO droplet, you could use a different way, but the whole flow should be similar or the same.

📧 Now, to setup SMTP for your Ghost:

1. Go to your project directory `cd /var/www/ghost`
2. Open to edit your `config.production.json`
3. Copy and paste config object for `mail` and fill `user` and `pass` with your creds

```
"mail": {
    "transport": "SMTP",
    "options": {
      "service": "Google",
      "host": "smtp.gmail.com",
      "port": 587,
      "auth": {
        "user": "your@google.email",
        "pass": "this password"
      }
    }
  },
```

You could burn down the paper with _this password_.

As a result, all your transactional emails should work fine without any additional pain in the ass. For example, now you could invite somebody else as a content contributor to your website.

## To conclude

If it will help at least one person, then these two hours were not a waste.

Any questions, experience, feedback? Feel free to drop a thoughtful comment. 

Have a nice day 🌞

p.s Thanks [Yannik Mika](https://unsplash.com/@yannikm?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) for suitable bg