Gmail Email Service Setup for Code-Based Email Sending

Email Pic

Email services play a crucial role in today’s software applications, allowing essential features like user verification and notifications. In this post, I’ll walk you through the process of setting up Gmail’s SMTP service. By the end, you’ll have the knowledge to send emails programmatically using your Gmail account.

Step 1: Create or Log In to a Gmail Account

To utilize Gmail’s SMTP service, you must have a Gmail account. If you don’t have one yet, follow the simple steps to create a new account. Alternatively, if you already have a Gmail account, proceed by logging in as usual.

Step 2: Go to your Account Settings

To navigate to your Account Settings, follow these steps:

Locate the Google apps button, which appears as a square made up of nine dots, typically located to the right of your profile picture.

Step 2 a Gmail Setting

Click on the Google apps button, and a menu will appear.

From the menu, select Account to access your Account Settings.

Step 2 c Gmail Setting
Step 3: Turn On Two-Factor Authentication

It is impossible to use Gmail’s SMTP service without turning two-factor authentication on. Hence, do the following to set it up.

a. Select the Security tab.

Step 3 a Gmail Setting

b. Go to the How you sign in to Google section.

Step 3 b Gmail Setting

c. Follow the required steps to set up Two-Factor Authentication in Google.

Step 4: Create an App Password

Google provides a handy feature called App Passwords, which makes email authentication a breeze for your software applications. Instead of using your usual password, you can generate a special app password dedicated to your code. This ensures a secure and seamless authentication process for sending emails programmatically.

Follow these steps to set up an app password.

a. Choose the 2-Step Verification option.

b. Click the App passwords option that is right at the bottom of the page.

Step 4 b Gmail Setting

Select Mail on the Select app drop-down list.

Step 4 c Gmail Setting

d. Select Other (custom name) on the Select device drop-down list.

Step 4 d Gmail Setting

e. Write a unique name for your app.

Step 4 e Gmail Setting