Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending email on behalf of another user

Currently I have used GMail API (OAuth Credential for Web) to read and send email messages. How can we send email on behalf of another user (i.e. [email protected])?

In enterprise application, do we need to use service account for reading specific user's mail labels, messages and send email on behalf of that user?

like image 571
Dinesh Prajapati Avatar asked Nov 27 '25 11:11

Dinesh Prajapati


1 Answers

Solution

Indeed you CAN send and read the mailbox of other user's in your domain with the Gmail API using a service account with domain wide delegation.

You will need to grant the service account with the Project Role of Owner using the domain wide authorization.

Apart from the official documentation linked above, here is a tutorial on how to send emails on behalf of other users using service accounts. To read from their mailbox you would follow the same process. Here is more information on mail delegation in case you are interested.

NOTE : in order to do this your service account must be in the same domain as the user's email you are trying to send and read messages from.

I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)

like image 70
Mateo Randwolf Avatar answered Nov 29 '25 00:11

Mateo Randwolf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!