Can I programmatically send email using my gmail account?

3

I have a gmail account.

Is there a Google API that allows me to log into this account and send emails?

Alex

Posted 2013-06-11T10:34:55.020

Reputation: 1 751

Answers

5

Yes. And the easiest way to find the documentation of it is by googling "gmail api".

See here.

You can also use any generic SMTP client. See Sending mail from a printer, scanner or app

Barmar

Posted 2013-06-11T10:34:55.020

Reputation: 1 913

your here link seems to be very broad, maybe it's meant to point to Gmail API Overview  |  Gmail API  |  Google Developers

– Wolf – 2017-04-18T08:43:12.097

Apparently they consider sending emails as "restricted" so to do it you need to pay $15000 and wait two months to get your project approved. I think it's much simpler to just use Gmail's SMTP as explained in this answer.

– Donald Duck – 2020-01-15T13:06:02.427

@DonaldDuck Got a reference to that? – Barmar – 2020-01-15T17:49:16.717

@Barmar I noticed it when I tried to use the API. Here are some screenshots: https://i.stack.imgur.com/yeShe.png and https://i.stack.imgur.com/YRxsQ.png. Also, in the second screenshot, the "internal" mode (which is the one that lets you send emails without getting your project approved) is only available to G Suite users and from what I've understood G Suite costs money.

– Donald Duck – 2020-01-16T20:16:45.657

@DonaldDuck I don't know what "sensitive scope" is, so I'm not sure if that message applies to all mail sending with the API or something more specific. – Barmar – 2020-01-16T20:32:37.660

@Barmar According to the first screenshot the scope that's needed to send emails (../auth/gmail.send) is considered "sensitive". If I try sending emails through the API without it I get errors about insufficient permissions. – Donald Duck – 2020-01-16T20:34:08.390

If I use the 2nd method, does the "from" still come from the gmail.com account? Or will it be my own domain name? I want the "from" to still be my gmail. – Alex – 2013-06-11T11:02:52.313

It's whatever the application puts in the From: header. – Barmar – 2013-06-11T11:05:21.357

@Alex - So indicate the address sending the email is your google account. You should be aware that Google has a limit on the number of emails you can send in a given day. If your using your account to advertise it will likely be locked down. – Ramhound – 2013-06-11T11:21:57.800

1

In a sentence: Just send email programmatically like you would with any other mail provider - using the SMTP protocol (over SSL): Connect to smtp.gmail.com on port 465 or 587, and give the username and password. On a UN*X system, you could use something like sendmail (or another MTA) + mailx, the latter being a command-line utility. See, e.g., here about using it.

einpoklum

Posted 2013-06-11T10:34:55.020

Reputation: 5 032

0

Yes, you can send email programmatically. You first need to generate appropriate application password, authenticate with the correct SMTP server and use SMTP client library to send email.

Follow this tutorial for more information (https://ps06756.wordpress.com/2017/08/17/how-to-send-email-through-gmail-programmatically/)

Pratik Singhal

Posted 2013-06-11T10:34:55.020

Reputation: 187