You can Still use Gmail SMTP to Send E-Mails in 2023 and Here's How

Some self hosted apps require email settings. Here's how you can use Gmail SMTP to send emails in 2023. ✉️

You can Still use Gmail SMTP to Send E-Mails in 2023 and Here's How

Not too long ago, Google made some changes with how they handle their SMTP mail sending ability. This created a panic online pretty much everywhere. People assumed Google was disabling SMTP mail sending when really all they did was change the process in which it's done.

Google used to handle SMTP through their "Insecure App" handling but that has recently changed to a more secure setting using 2FA and Google app passwords.

How to Setup Gmail SMTP Sending in 2023

In order to use Gmail SMTP mail sending, you must log into your Google account settings under Security, enable 2FA then create an app password. That app password will be the password you use in your SMTP settings.

  1. Enable 2FA

2. Create an App password and give it a name related to your project. This will be on the same 2FA page at the very bottom. (they keep changing this!) (updated 9/1/2023)

When you generate the password, it will give you a 16 character, lowercase, all alpha password. Save this password somewhere safe so you can find it later if you need it.

Gmail SMTP Example

Here is an example of what most SMTP settings require.

Host: smtp.gmail.com
Port: 587
Encryption: TLS
User: [email protected]
Password: xmmpzcxmfhwyzdja

You can change the port to 465 and encryption to SSL if you prefer. I find TLS works better for me without any issues. Also, when using the app password, there should be no spaces. I am not sure why Google shows the spaces when the password is generated because all it does is create more confusion. So I'll spare you the headache and tell you that now.

Bonus: Setup Gmail SMTP Sending in Ghost

You can use Gmail SMTP sending for Ghost such as signups, account notifications and comment notifications.

Currently, Ghost doesn't make it easy to change the mail settings. You have to do a bit of digging to make it work. Here is how to setup Gmail SMTP to work with Ghost blog platform.

  1. Find the config.production.json file located in /var/lib/ghost and add the following "mail" section.
{
  "url": "http://localhost:2368",
  "server": {
    "port": 2368,
    "host": "::"
  },
  "mail": {
    "transport": "SMTP",
    "options": {
      "service": "Google",
      "host": "smtp.gmail.com",
      "port": 587,
      "auth": {
        "user": "[email protected]",
        "pass": "yourapppasswordhere"
      }
    }
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}

2. Save the config.production.json file and reboot the Ghost server Docker container.

3. Subscribe a new account to make sure it's working. It is best to use a different email than the one you are using for SMTP sending for the test.

Note: This will not work for newsletter sending and rightfully so. Standard Gmail accounts are limited to 500 outgoing emails per day. Ghost uses Mailgun for newsletter sending which is a pretty decent service and it's what we use for Noted.

Final Notes and Thoughts

There are guides out there that are outdated and misinforming people making them think Gmail SMTP sending no longer works. In reality it does work but there are not many good resources explaining how it's done now.

Give it a try in your self hosted application and see for yourself. If you have any questions, come on back and shoot me a comment below and I'll do my best to help you get it working.