问题
When I send an email using the GMail API, I get an Access Token for the user to whom the message is to be sent and then when sending the message, I put some value in the From Field.
But no matter what I put in the from field, the message in the email shows as From "Me" and is in the Sent mails as well as Inbox.
Is there a way, I could use the Service Account to send the email, so that it does not show up as From "Me" and is also not in the Sent Mails.
回答1:
Contrary to what the other answers say (with the utmost respect), you can send emails via a service account - I've done so myself from a paid Google account.. In other words, you can use a service account to send emails programmatically from your personal email account: e.g. washinton.irving@gmail.com
. I thought to add this answer to reflect this reality; The link which explains it all can be found below:
https://medium.com/lyfepedia/sending-emails-with-gmail-api-and-python-49474e32c81f
Here is a summary contained within the above tutorial:
- Turn on the Gmail API and create a service account with domain-wide authority.
- Authorize the service account to send emails.
- Send emails with a Python/Ruby etc. script.
The link above shows it all in detail and I hope that helps.
Another alternative:
You can create a separate password that your app uses to access your gmail account. You'll have to go into your gmail settings, and create a password which a particular app can use.
回答2:
No. The Gmail API is for Gmail users and service accounts are just for doing auth to a real Gmail account, they don't have their own Gmail account, etc.
If you want to send the email from some service, you need some bulk-sending email service like at: https://cloud.google.com/compute/docs/tutorials/sending-mail/ or something you run yourself or from some other provider.
回答3:
No, what you are looking for is a bulk email sending service. Checkout sendgrid , Amazon AWS SES, mandrill or if you want to stick with Google, this. You could of course run your own postfix server (although I'm assuming you were using gmail api for deliverability in the first place.
来源:https://stackoverflow.com/questions/33233694/gmail-api-can-i-send-email-using-the-service-account