简体   繁体   English

代表其他用户发送电子邮件

[英]Sending email on behalf of another user

Currently I have used GMail API (OAuth Credential for Web) to read and send email messages.目前我使用 GMail API(OAuth Credential for Web)来阅读和发送电子邮件。 How can we send email on behalf of another user (ie noreply@example.com)?我们如何代表另一个用户发送电子邮件(即 noreply@example.com)?

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?在企业应用中,我们是否需要使用服务帐户来读取特定用户的邮件标签、消息并代表该用户发送电子邮件?

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 .实际上你可以使用Gmail的API发送和阅读其他用户对邮箱服务帐户域宽代表团

You will need to grant the service account with the Project Role of Owner using the domain wide authorization.您将需要使用域范围的授权授予具有Owner Project Role的服务帐户。

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.如果您需要其他任何东西或者您不理解某些东西,请告诉我。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM