Gmail SMTP and Security settings for sending email

Introduction

Here I am going to show you how to do Gmail SMTP and Security settings for sending email using programming language. You can use any server side technology for sending email using Gmail SMTP server.

This example will show you only what configurations you need in order to send email and it does not show any concrete example for sending email.

This post will also show you how to reduce the security level in Gmail settings to send email otherwise you will get an error even if you use correct username and password for sending email.

What is SMTP?

So SMTP stands for Simple Mail Transfer Protocol and is the most popular across all major providers and standard way for sending email.

Gmail SMTP Settings

Here is the default SMTP settings you can use to send email from your Gmail account to other gmail accounts.

SMTP Server or Host: smtp.gmail.com
SMTP username: your gmail address
SMTP password: your gmail address's password
SMTP port: 587 (TLS), 465 (SSL)
SMTP TLS/SSL required: Yes
SMTP starttls required: Yes

Known Issues

Must issue a STARTTLS command first

Now if you do not enable starttls then you may get the following error:

Must issue a STARTTLS command first

Therefore you must enable starttls to send email using Gmail SMTP server.

BadCredentials

You will get below error if your security level is high.

Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/?p=BadCredentials

So you need to lower your security level in Gmail account settings. Read the following section to configure security settings.

Security Settings

You need to change in security settings for your Gmail account from which you want to send email.

Find below steps in order to change Gmail account’s security settings:

Go to your Gmail account settings (gear icon) as shown in the below image and click on Other Google Account settings.

gmail smtp and security settings for sending email

Now click on Security on left menu as shown in below image:

gmail security

Next click on Turn on access (not recommended) for less secure app access.

gmail smtp

Click on to activated the area as highlighted in the below image:

gmail security settings

Now you would be able to send the email using Gmail SMTP server without any error.

That’s all about lowering the security settings in Gmail.

Leave a Reply

Your email address will not be published. Required fields are marked *