简体   繁体   English

python服务器端程序来处理电子邮件?

[英]python server-side program to handle email?

What is the easiest way to write a simple Python daemon/server-side program that, in a reasonably secure way, processes incoming messages from an email account? 编写简单的Python守护程序/服务器端程序(以合理安全的方式处理来自电子邮件帐户的传入消息)的最简单方法是什么? For example, if you have an account 'foo@bar.org' and you have the username/password to the program, you want to be able to have the program read the contents of the email and save them to a database (eg with sqlite ) in Python. 例如,如果您有一个帐户“ foo@bar.org”,并且拥有该程序的用户名/密码,则希望该程序能够读取电子邮件的内容并将其保存到数据库中(例如sqlite )。 What's the best framework/library for doing this? 最好的框架/库是什么? It sounds like it might be overkill to use Django for something so simple -- can it be done purely with the Python standard libraries? 听起来听起来像用Django做这么简单的事情可能会过头了-可以完全用Python标准库完成吗?

There are python poplib ( http://docs.python.org/2/library/poplib.html ) and python imaplib ( http://docs.python.org/2/library/imaplib.html ). 有python poplib( http://docs.python.org/2/library/poplib.html )和python imaplib( http://docs.python.org/2/library/imaplib.html )。 For accessing mailboxes. 用于访问邮箱。

Then you have lamson ( http://lamsonproject.org/ ), which is not only excellent for sending and recieving mails. 然后就是lamson( http://lamsonproject.org/ ),它不仅非常适合发送和接收邮件。 But it can also help you with parsing messages, detecting if they are spam or not - look into lamsons code to see exactly what you can do with it. 但它也可以帮助您解析邮件,检测邮件是否为垃圾邮件-查看lamsons代码以确切了解您可以使用该邮件做什么。

Then there are many examples of python daemons, which you can periodically run to pick up mails using poplib/imaplib and then save them somewhere using sqlalchemy or django or whatever. 然后有许多python守护程序的示例,您可以定期运行这些示例以使用poplib / imaplib提取邮件,然后使用sqlalchemy或django或其他方法将其保存在某处。

OR you could skip python daemons and rather create small django project for doing all that. 或者,您可以跳过python守护程序,而是创建一个小的django项目来完成所有这些工作。 Combined with Celery ( https://pypi.python.org/pypi/django-celery ), you can create excellent daemonized backend for accessing mailbox via POP or IMAP and saving stuff to your own database. 结合Celery( https://pypi.python.org/pypi/django-celery ),您可以创建出色的后台守护进程,以通过POP或IMAP访问邮箱并将内容保存到自己的数据库中。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM