4

I have a gmail account.

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

fixer1234
  • 27,064
  • 61
  • 75
  • 116
Alex
  • 2,391
  • 14
  • 35
  • 48

3 Answers3

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
  • 2,341
  • 17
  • 22
  • 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 Jun 11 '13 at 11:02
  • It's whatever the application puts in the `From:` header. – Barmar Jun 11 '13 at 11:05
  • @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 Jun 11 '13 at 11:21
  • your **here link** seems to be very broad, maybe it's meant to point to [Gmail API Overview  |  Gmail API  |  Google Developers](https://developers.google.com/gmail/api/guides/) – Wolf Apr 18 '17 at 08:43
  • 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](https://superuser.com/a/723401/513819). – Donald Duck Jan 15 '20 at 13:06
  • @DonaldDuck Got a reference to that? – Barmar Jan 15 '20 at 17:49
  • @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 Jan 16 '20 at 20:16
  • @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 Jan 16 '20 at 20:32
  • @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 Jan 16 '20 at 20:34
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
  • 8,783
  • 20
  • 84
  • 153
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
  • 187
  • 1
  • 8