How to setup basic SMTP for Ghost

How to setup basic SMTP for Ghost

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).

:old_key: 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.

:e-mail: 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.

Originally published on How to setup basic SMTP for Ghost - DEV Community šŸ‘©ā€šŸ’»šŸ‘Øā€šŸ’»

3 Likes

For anyone who gets hung up on making an app password, Google only offers this option if you have 2FA turned on. So that’s your first step! :slight_smile:

Hope that helps someone else!

This works great for transactional emails on my Windows-running development setup.

2 Likes

However, if appears that Ghost only supports non-2FA gmail - so it is not possible to use a personal non-2FA gmail account for Ghost - correct? What are the Google alternatives for using their SMTP server?

Welcome to Ghost, @Michael_Lavelle !

I have 2FA on my personal Gmail, and I’m using that to send Ghost transactional emails on a couple of dev setups. (For production, I use mailgun for transactional email or else my own SMTP server.)

You can turn 2FA on pretty easily for a Gmail account. I don’t think it costs anything or needs special account access. Ghost doesn’t actually USE 2FA when it connects to Google’s SMTP server - it uses the app password, it’s just that you need to have app passwords available, which requires 2FA.

I’ve got a few more details about that setup here: How to deliver Ghost emails from your local dev setup

You certainly don’t have to use Gmail. You could instead configure an outgoing mail server and tell Ghost to use it, or you could set up a mailgun account (needed for newsletters anyway) and tell Ghost to use that. There are options described here:

I think at this point I’ve done all the options listed for transactional email except SES. None of them are terrible to set up, but if you really don’t want to do server setup or any sort, you might also want to give Ghost Pro another look, since they make all that stuff ā€˜just work’.

Thank you for this fast response. Turns out the ā€œserviceā€ line was preventing Ghost from starting properly - deleting it solved that problem. Looks like email is working now. Interestingly I found several references that included the ā€œserviceā€ line and several that did not. It might be that mailgun requires the ā€œserviceā€ line. In any case thank you so much. Mike

2 Likes

I’m glad that you were able to get it working, and thanks for coming back to document the fix!!

@chakzefir Do you know how to set it up so that it uses an preconfigured alias?

I’ve setup an alias on my gmail that is noreply@mywebsite.com, and I want to use that instead of my own gmail address.

I’ve tried using that alias as options.auth.user, and as options.from, but the mails that it sends still show my original gmail address.

Hey bazoo,

I think you rather need to create dedicated email address and setup the same for noreply@mywebsite.com