如何使用随机的非应用程序管理员发件人从 Google App Engine 发送电子邮件?

发布于 2024-11-29 05:14:48 字数 133 浏览 2 评论 0原文

Google App Engine 有一条规则,只允许应用管理员发送电子邮件。 是否有任何人使用的解决方法从非管理地址发送电子邮件?

我正在构建一个 B2B 白标平台,能够在不授予客户管理员访问权限的情况下屏蔽“FROM”地址非常重要。

Google App Engine has a rule of only allowing app admins to send email.
Is there a workaround that anyone out there is using to send emails from non-admin addresses?

I'm building a B2B white-label platform, and being able to mask the "FROM" address is very important without giving my customers admin access.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

━╋う一瞬間旳綻放 2024-12-06 05:14:48

文档还指出:

应用的任何有效电子邮件接收地址(例如[电子邮件受保护]).


因此,您可以根据该地址创建一个发件人地址,甚至在有人回复时将该电子邮件正确路由回您的应用程序。

The docs also state:

Any valid email receiving address for the app (such as [email protected]).

So you can make up an sender address based on that, and even correctly route that email back into your app if anyone replies to it.

独留℉清风醉 2024-12-06 05:14:48

还可以代表登录用户发送电子邮件(假设该用户使用的是 Google 帐户)。

user = users.get_current_user()
message = mail.EmailMessage(sender=user.email())    

#Set other message components, such as message.body

try:
  message.send()
except:
  message.sender = #An APP-ID.appspotmail.com address, or Admin address
  message.send()

It is also possible to send email on behalf of a logged in user, assuming that user is using a Google Account.

user = users.get_current_user()
message = mail.EmailMessage(sender=user.email())    

#Set other message components, such as message.body

try:
  message.send()
except:
  message.sender = #An APP-ID.appspotmail.com address, or Admin address
  message.send()
枯寂 2024-12-06 05:14:48

如果您需要电子邮件看起来像是由用户发送的,并且在回复时回复到该用户的实际电子邮件地址,那么您可以使用reply_to。

user_name = 'Some Guy'
user_email = '[email protected]'
admin_email = '[email protected]'
from_email = '%s <%s>' % (user_name, admin_email)
reply_to = '%s <%s>' % (user_name, user_email)
mail.send_mail(from_email, to_email, subject, body, reply_to=reply_to)

这样,对于接收电子邮件的人来说,它会显示为来自 user_name,如果他们回复,那么他们的回复电子邮件将发送到 user_email。

这种方法的主要缺点是,如果有人仔细查看收到消息的地址,他们会看到管理员电子邮件地址,但大多数电子邮件客户端会更突出地显示该名称。

从好的方面来说,您可以作为任何电子邮件地址发送,大多数人永远不会注意到它来自管理员电子邮件地址。

If you need the email to appear as if it was sent by a user and when replied to reply back to that user's actual email address then you can make use of reply_to.

user_name = 'Some Guy'
user_email = '[email protected]'
admin_email = '[email protected]'
from_email = '%s <%s>' % (user_name, admin_email)
reply_to = '%s <%s>' % (user_name, user_email)
mail.send_mail(from_email, to_email, subject, body, reply_to=reply_to)

This way to the person receiving the email it will appear that it came from user_name and if they reply then their reply email will be sent to user_email.

The main negative of this approach is that if someone looks closely at the address they received the message from they will see the admin email address but most email clients show the name more prominently.

On the plus side you can send as any email address and most people would never notice it came from an admin email address.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文