Set Up a Gmail SMTP
Gmail is one of the most popular email services in the world. Set up a secure SMTP with Google and Acquire.
In this article:
- Creating a Google Project
- Creating OAuth 2.0 API Credentials
- Generating OAuth 2.0 Playground Tokens
- Adding Gmail Credentials to Acquire
- Verifying the SMTP Configuration
What you'll need:
- A Google Developer account. If you do not have an account, please create one first before proceeding with this guide.
Creating a Google Project
To generate a Gmail SMTP, you’ll need an API key. To generate a key, log in to your Google Developer Console account. From the Dashboard, select your project. (In the example below, acquire-bot was selected).
Then, select ‘New Project’.
Enter the project name, where you would like to save it, and then press ‘Create’.
Creating OAuth 2.0 API Credentials
OAuth credentials will be needed to generate a client id. A client id helps Google's OAuth servers identify our app so that we can securely send emails from Nodemailer.
Press the triple lines (‘≡’) next to Google Cloud Platform to open the sidebar. Then select APIs & Services > Credentials.
Before proceeding, you may need to configure the consent screen. The consent screen configuration is important when an application offers Google Sign In.
Click on ‘Configure Consent Screen’.
Select ‘External’ for the User Type and then click on ‘Create’.
You will be directed to the App Registration page. You’ll be asked to provide the required information:
- The app's name
- Your email address
- The developer's email address (which can be your email address)
Optionally, you may input the following information:
- Your app logo (if applicable)
- Your app name
- The data you are requesting, or scopes, which you will add in the next step
- Test users
Input all required information.
Once you've completed the consent screen, go to the 'APIs and Services' > 'Credentials' section. Click on 'Create Credentials'. Then select 'OAuth client ID'.
Copy the client ID and client secret shown on the screen and save it for later.
In the Authorized redirect URIs section, paste "https://developers.google.com/oauthplayground" in the URIs input field. Then, hit 'Save'.
Generating OAuth 2.0 Playground Tokens
A refresh token and access token may now be generated from the client id and secret.
Start by visiting Google Developers OAuth 2.0 Playground.
Once on the page, click the gear icon and check the ‘Use your own OAuth credentials’ box. Then paste the client id and secret.
On the next screen, click ‘Allow’ so that Google OAuth 2.0 Playground has access to your Google account.
Select https://mail.google.com from the API list, then press ‘Authorize APIs’.
On the next screen, press 'Allow' to authorize the API. After being redirected back to the OAuth 2.0 Playground, go to the left panel, and click the ‘Exchange authorization code for tokens’ button.
Once the refresh and access token is generated, copy the refresh token and save it for later.
Add Gmail Credentials in Acquire app
Log in to the Aquire Platform, click on the Settings > Email-Setup > SMTP tab.
Next, click on the ‘Create SMTP’.
Enter the SMTP name and select theService Type as ‘Gmail’ from the drop-down.
Next, enter the following information into the newly generated fields:
- Enter your Gmail Client ID, Client Secret, Client Email Address, and Refresh Token in the respective fields.
- Finally, click on the ‘Save’ button.
Verifying the SMTP Configuration
Acquire gives you the option to test your SMTP setup immediately after configuration. Verify if emails are dispatched from the server by sending a test email to yourself. To test your SMTP, go to Settings > Email Setup and select the SMTP tab.
First, click on the three dots (‘...’) beneath the ‘Action’ heading. Select ‘Send Test Email’ from the drop-down menu.
Enter your email address as the recipient in the SMTP Email field.
Finally, click ‘Send Email’.
You will be notified once the test email is successfully sent. An email should also appear in the specified inbox.