将电子邮件重定向到Python脚本的最佳方法是什么? [英] What is the best way to redirect email to a Python script?

查看:71
本文介绍了将电子邮件重定向到Python脚本的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的网站用户提供一项功能,以便在注册时为其分配电子邮件地址(例如firstname.lastname@mydomain.com),但是我真的认为实际上支持所有这些功能并不可行。电子邮件帐户通常通过网络邮件程序。我也不确定我的虚拟主机是否会很酷。我真正想要的是能够将此电子邮件无缝集成到该网站所在的更大系统中,因为这主要用于网站内消息传递,但我们希望允许用户输入实际的电子邮件地址。因此,我想做的是在mydomain下拥有一个通用帐户,并让该电子邮件查看传入的邮件,查看将其发送给谁,并在系统中为用户添加一条消息。



因此,问题是:



1)这是正确的方法吗?获得一个主机,让我可以随意将电子邮件分配到我的域,这将有多昂贵?我目前正在使用WebFaction的共享托管。

2)如果可以的话,将所有捕获的帐户路由到我的python脚本的最佳方法是什么?我已经读过有关.forward的文章,但是我对UNIX的知识不是很熟练。一旦弄清楚了,如何将脚本放入 Django环境中,以便可以使用Django的模型功能向用户添加新消息?

3)Django有什么可以做的

4)Python中是否有任何工具可以帮助我解析电子邮件地址?它们如何工作?

解决方案

直接回答您的问题:



1,2)查看 WebFaction网站上的此FAQ 。它说明了如何轻松地将传入的电子邮件路由到您选择的脚本中。创建电子邮件地址时,您不能仅指定用户名以使其成为发送到域的所有内容都包含的所有电子邮件。



3)和其他用户一样建议,您可以查看 django消息,但是也许 Django Plugables 有更好的选择。



4)查看 email.parser 模块,因为它处理了解析电子邮件的大多数令人恐惧的部分。 / p>

I'd like to provide a functionality for users of my website to get assigned an email address upon registration (such as firstname.lastname@mydomain.com) but I don't really think it is feasible to actually support all these emails account normally through a webmail program. I am also not sure if my webhost would be cool with it. What I'd really want is to be able to have a seamless integration of this email into the bigger system that the website is, as it is mostly going to be for intra-site messaging but we want to allow users to put actual email addresses. So what I would like to do instead is have a catch-all account under mydomain and have this email look at incoming mail, see who it was meant to be sent to, and add a message for the user in the system.

So, the questions are:

1) Is this the right approach? How expensive would it be to get a host that would allow me to just assign emails to at will to my domain? I am currently using WebFaction's shared hosting.
2) If it is an okay approach, what is the best way to route this catch all account to my python script? I have read about .forward but I am not very good at UNIX stuff. Once I figure that out, how would I get the script to be in the "Django environment" so I can use Django's model functionality to add the new messages to the user?
3) Is there anything Django can do to make this any easier?
4) Are there any tools in Python to help me parse the email address? How do they work?

解决方案

To directly answer your questions:

1,2) Check out this FAQ in the WebFaction website. It explains how to easily route incoming emails into the script of your choice. When creating an email address, you can just not specify a username to make it be a catch-all email that anything sent to the domain goes to.

3) As others have suggested, you could check out django-messages, but maybe Django Plugables has something better.

4) Check out the email.parser module as it takes care of most of the scary parts of parsing emails.

这篇关于将电子邮件重定向到Python脚本的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆