Setting up SMTP Email for a Google Workspace Account - Send Email via an App

The Problem

  1. You have an app.
  2. You want the app to send outgoing emails,
  3. via Google workspaces
  4. via SMTP

…how do you do this?

The Solution

  1. First, set up an app password: https://myaccount.google.com/apppasswords

Store the app name and the password.

  1. Set up your SMPT credentials on your app:

For example on rails, I need to do this:

# the app user name and password will be very different
# from the username password combination for your
# google workspaces account:

  config.action_mailer.smtp_settings = {
    :address              => "smtp.gmail.com",
    :port                 => 587,
    :user_name            => ENV['gmail_app_username'],
    :password             => ENV['gmail_app_password'],
    :authentication       => "plain",
    :enable_starttls_auto => true
  }
Written on January 16, 2025