问题
I created a script that connects with the Gmail API using OAuth 2.0. It works perfectly, and I am able to send email from the authenticated account.
However, I can't send email from any of the account's aliases. If I try to do so I get the following error message:
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "[ACCOUNT] does not have privileges to [ALIAS] mailbox."
}
],
"code": 403,
"message": "[ACOUNT] does not have privileges to [ALIAS] mailbox."
}
}
I have verified that the alias is setup in Gmail and Google Apps.
Anyone have any ideas?
回答1:
Don't try to make the call as the alias (e.g. alias shouldn't be in the URL as the user ID), just put the alias email address in the "From" header in your sent message.
so in python would be something like:
email = "To: someone@example.com\r\nFrom: myalias@gmail.com\r\nSubject: blah\r\n\r\nbody goes here"
gmail.users().messages().send(userId="me", body={'raw': base64.urlsafe_b64encode(email)})
回答2:
i found same error..
when i add user i use for sendmail on https://www.google.com/webmasters on domain i used, and on https://admin.google.com for API access
and now it's work..
hope this help..
来源:https://stackoverflow.com/questions/25485963/gmail-api-send-from-alias