DEV Community

Cover image for How to setup basic SMTP for Ghost
chakzefir
chakzefir

Posted on

How to setup basic SMTP for Ghost

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 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"
      }
    }
  },
Enter fullscreen mode Exit fullscreen mode

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 for suitable bg

Top comments (3)

Collapse
 
sivaneshs profile image
Sivanesh Shanmugam

This is an eye opener for me. Thank you so much for posting this!โค๏ธ

Collapse
 
a2br profile image
a2br

Helped me a lot! It's a great temp solution to use a Gmail account, but I'm still trying to find out how to use my own domain name.

Collapse
 
dave_v_e45281c1308c4ba340 profile image
Dave v

Nice post. How can I configure SMTP in Docker?