如何构建像 Facebook 一样的通知电子邮件/回复系统?
当用户在 Facebook 上收到有关新私人消息的通知电子邮件时,他们可以回复该电子邮件,并将其回复自动添加到网站上的对话中。
如何构建这样的跨平台系统?我正在建立一个群聊系统。
When users receive a notification email about a new private message on Facebook, they can reply to the email and have their response automatically added to the conversation on the site.
How can I build a cross platform system like that? I'm building a group chat system.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这显然过于简单化了,但我们开始吧:
Facebook 电子邮件的工作方式是在回复地址中使用收件人独有的字符串:
因此,当 Facebook 收到一封发送到
的电子邮件时code>reply.facebook.com
,他们(大概)解析加号后面的字符串,决定它与哪个用户/对话相关,并将电子邮件的文本添加到该对话中。This is obviously way over-simplified, but here we go:
The way Facebook's emails work is by using a string that's unique to the receiver in the
reply-to
address:So when Facebook receive an email into
reply.facebook.com
, they (presumably) parse the string after the plus sign, decide which user/conversation it's relevant to, and add the text of the email into that conversation.一种选择:
发送带有唯一回复地址的每封通知电子邮件,然后使用自定义 SMTP 服务器接收回复,该服务器会将响应与数据库中的原始消息对象配对。
由于您使用的是 django (根据您的标签),我建议您查看 Lamson python SMTP 服务器。它可以被编程为正确地归因每条消息。将 Lamson 与 Django 结合使用已记录。
One option:
Send every notification email with a unique reply-to address, then receive replies with a customized SMTP server that will pair responses with the originating message object in your DB.
Since you are using django (according to your tags) I would recommend looking at the Lamson python SMTP server. It can be programmed to correctly attribute each message. Using Lamson with Django is documented.