测试本地集成测试的SMTP/IMAP服务器
localmail的Python项目详细描述
本地邮件
对当地人来说。
localmail是一个smtp和imap服务器,它将所有邮件存储到一个 内存邮箱。它被设计用来加速在 发送电子邮件的系统,如带有确认信息的新帐户注册电子邮件 代码。它还可以用于测试smtp/imap客户端代码。
功能:
- Fast and robust IMAP/SMTP implementations, including multipart messages and unicode support.
- Includes simple HTTP interface for reading messages, which is useful for checking html emails.
- Compatible with python’s stdlib client, plus clients like mutt and thunderbird.
- Authentication is supported but completely ignored, all message go in single mailbox.
- Messages not persisted by default, and will be lost on shutdown. Optionally, you can log messages to disk in mbox format.
缺少功能/待办事项:
- SSL support
警告:不是真正的SMTP/IMAP服务器-不用于生产用途。
运行本地邮件
twistd localmail
这将在后台运行localmail,在端口2025上运行smtp,在2143上运行imap, 它将记录到一个文件中。如果要在中运行,请使用-n选项 前景,就像这样。
twistd -n localmail
您可以将参数传递给控制参数。
twistd localmail --imap <port> --smtp <port> --http <port> --file localmail.mbox
如果愿意,可以让localmail使用随机端口。将记录端口号。 TOdo:启用将随机端口号写入文件。
twisted -n localmail --random
嵌入
如果要将localmail嵌入到另一个非扭曲程序中,例如test Runner,执行以下操作。
importthreadingimportlocalmailthread=threading.Thread(target=localmail.run,args=(2025,2143,8880,'localmail.mbox'))thread.start()...localmail.shutdown_thread(thread)
这将在一个单独的线程中运行扭曲的反应器,并在 出口.
如果要使用随机端口,可以传递一个回调,该回调将具有 服务正在侦听的端口。
importthreadingimportlocalmaildefreport(smtp,imap,http):"""do stuff with ports"""thread=threading.Thread(target=localmail.run,args=(0,0,0,None,report))thread.start()
历史记录
0.4(2015-08-14)
- support for using random port numbers
- available as a universal wheel, general packaging improvements
- Simple HTTP interface for browsing mail (requires jinja2)
- Support writing to mbox file
- Fixed date to work with mutt, example muttrc included in package.
0.3(2013-05-24)
- Multipart message support [via Ed Jannoo]
- IMAP UID support
- Support python 2.6, 2.7 and pypy, tested via tox
0.2(2012-11-13)
- Initial public release
- Basic SMTP/IMAP server
学分
“localmail”由simon davy编写和维护
贡献者
以下人员直接或间接参与了本项目:
- ed jannoo<;ed@azordi.com>;