google-app-enginegmail-apigoogle-groups

How to send an email on behalf of a Google Group with the GMail API


We would like our application to send emails with a google group email in the FROM header.

This is possible in the GMail interface, assuming that the Google Group is correctly configured.

But when we try with the GMail API here's the error we got :

403 Forbidden

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  175
content-type:  application/json; charset=UTF-8
date:  Thu, 04 Sep 2014 11:05:36 GMT
expires:  Thu, 04 Sep 2014 11:05:36 GMT
server:  GSE

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "XXX.XXXX@XXXXX.XXX does not have privileges to XXX.XXXX@XXXXX.XXX mailbox."
   }
  ],
  "code": 403,
  "message": "XXX.XXXX@XXXXX.XXX does not have privileges to XXX.XXXX@XXXXX.XXX mailbox."
 }
}

Is there a way to circumvent this, either with the GMail API or with App Engine's mail features ?


Solution

  • Don't try to put the group in the URL, just use "me", the authenticated user as normal. If that user really does have the group configured as a valid From address in the gmail web interface (they have to have completed a verification flow to confirm they own the address by clicking on a link--they can send emails "From" that group using the web interface) then you should simply be able to send an email with the "From" header being that group and it will be accepted.