python - 从登录我的 GAE 应用程序的用户发送电子邮件

标签 python google-app-engine gmail

假设我有用户在我的 GAE 应用程序中注册了他们用来访问 GMail、日历、联系人等的 Google 帐户。他们确认我的应用程序可以从他们的 GMail 帐户发送电子邮件,并且当他们单击某个链接时,例如“向我所有的 friend 发送通知”,该消息会从用户的 GMail 帐户发送到其应发送的位置。是否可以在不要求用户与我的应用程序共享其登录名和密码的情况下完成此操作?

最佳答案

来自 GAE Mail API文档:

The email address of the sender, the From address. The sender address must be one of the following types:

  • The address of a registered administrator for the application. You can add administrators to an application using the Administration Console.
  • The address of the user for the current request signed in with a Google Account. You can determine the current user's email address with the Users API.
  • Any valid email receiving address for the app (such as xxx@APP-ID.appspotmail.com).

因此,如果他们使用 Users API 登录您的应用,您只需将发件人设置为与用户帐户关联的电子邮件地址即可:

message.sender = users.get_current_user().email()

关于python - 从登录我的 GAE 应用程序的用户发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5836036/

相关文章:

python - 带有表单的 Django DetailView

python - 绘制精确解(错误)

java - 在控制台中监控 google app engine cron 作业?

android - 是否有任何简单的阅读新 gmail 邮件的简短代码示例?

javascript - gmail如何实现 'add link to mail'功能?

php - 使用 IMAP/SMTP 在 Gmail 中创建邮件(即草稿)?

python - 不使用pygrib包读取grib2格式数据

python - 模型错误 : Layer model_1 expects 1 input(s), 但它收到了 2 个输入张量

python - (Python) Google App Engine 中的依赖注入(inject)

java - setDefaultHighRepJobPolicyUnappliedJobPercentage(100) 真的有效吗?