简体   繁体   English

如何使用随机的非应用管理员发件人从 Google App Engine 发送 email?

[英]How do I send email from Google App Engine with a random, non-app admin sender?

Google App Engine has a rule of only allowing app admins to send email. Google App Engine 的规则是只允许应用管理员发送 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.我正在构建一个 B2B 白标平台,并且能够屏蔽“FROM”地址非常重要,而无需授予我的客户管理员访问权限。

The docs also state:文档还有 state:

Any valid email receiving address for the app (such as xxx@APP-ID.appspotmail.com).应用程序的任何有效 email 接收地址(例如 xxx@APP-ID.appspotmail.com)。

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.因此,您可以根据该地址组成一个sender地址,如果有人回复它,甚至可以正确地将 email 路由回您的应用程序。

It is also possible to send email on behalf of a logged in user, assuming that user is using a Google Account.还可以代表登录用户发送 email,假设用户使用的是 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()

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.如果您需要 email 看起来好像它是由用户发送的,并且在回复时回复该用户的实际 email 地址,那么您可以使用 reply_to。

user_name = 'Some Guy'
user_email = 'some.guy@whatever.com'
admin_email = 'no-reply@yourdomain.com'
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.这样对于接收 email 的人来说,它似乎来自 user_name,如果他们回复,那么他们的回复 email 将被发送到 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.这种方法的主要缺点是,如果有人仔细查看他们收到的消息的地址,他们会看到管理员 email 地址,但大多数 email 客户端会更显眼地显示该名称。

On the plus side you can send as any email address and most people would never notice it came from an admin email address.从好的方面来说,您可以发送任何 email 地址,大多数人永远不会注意到它来自管理员 email 地址。

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

相关问题 如何与随机发件人一起从Google App Engine发送电子邮件? - How do I send email from Google App Engine with a random sender? 发送电子邮件烧瓶Google App引擎-无效的发件人格式 - Send email flask google app engine - Invalid sender format 如何在Google App Engine中验证收到的电子邮件地址的发件人? - How to verify sender of incoming email address in Google App Engine? 从Google App Engine发送电子邮件警报 - Send Email alerts from Google App Engine 无法从Google App Engine发送电子邮件 - Unable to send email from google app engine 如何从Google App Engine向Android应用发送数据? - How do I send data to an android app from Google App Engine? 使用App Engine上的NEW控制台添加域后,如何从域帐户发送电子邮件? - How do I send email from a domain account when the domain was added using the NEW console on App Engine? 如何在Google App Engine Django非相关项目中实现发送电子邮件功能 - How to implement send email functionality in google app engine django non-rel project 通过Google App Engine上的Google Apps昵称发送电子邮件 - Send email from a Google Apps nickname on Google App Engine 从远程主机发送带有谷歌应用引擎的电子邮件,如何附加文件? - sending email with google app engine from remote host, how do I attache a file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM