phen的邮件服务插件
phen.mail的Python项目详细描述
Note: this is alpha software, use it only if willing to help debug it.
此插件提供完整的邮件服务:
- 中继:签署邮件消息(DKIM)并将其传输到其他 服务器
- 通过Smarthost中继:将邮件转发到配置的SMTP 执行中继的服务器
- 传递:接收和过滤消息,然后将它们传递给phen 邮箱、其他插件或外部代理(如Dovecot LDA)
- 获取:从其他服务器检索邮件
- 访问:通过imap4、pop3或direct shell提供消息 管理层
当与phen的dns插件一起使用时,传出的邮件将通过 常见的反垃圾邮件测试。模块dkinpy(debian中的python dkim)是 需要DKIM签名。
其他插件可以使用send_mail方法轻松地发送邮件。
服务器配置
Note: all configuration files are in JSON format, but allow hash (#) comments.
使用 以下参考:
{ "sender-domain": "example.com", "receivers": [ # DNS MX records (requires dns plugin) [0, "mail1.example.com"], # priority, server name [5, "mail2.example.com"], ], "domains": { "example.com": { "postmaster": ":alice", "abuse": ":alice", "alice": "/[user-identity]/path/to/mail-folder", "bob": "-disabled account", "carol": ">external-MDA-command parameters [hashed-passphrase]" "dan": ">forward@domain.org [hashed-passphrase]" "robot": ".plugin-name parameters" } }, "relay": { "dkim-key": "/[device-identity]/system/mail/dkim.key", # default "queue-folder": "/[device-identity]/system/mail/queue" # default }, # if instead of relaying by yourself you prefer/need a smarthost: # "hosted": { # "server": "smtp.example.com", # "port": 587, # default # "username": "user@example.com", # "password": "KTgyfDNrNH0kbCkCKgMtAi4D", # "require-tls": false # }, "imap": true, "pop": {"port": 111, "disable-ssl": true} }
请记住,rfc822 6.3、rfc1123 5.2.7要求邮件服务器, 以及rfc2821 4.5.1,以获得有效的postmaster地址,并通过rfc2142 第2节要有一个有效的abuse地址。
如果要更改 默认值。例如,引用中的relay部分 上面的可以用"relay": true替换。
用户定义字符串的第一个字符将操作设置为 接收或转发邮件时拍摄:
-禁用对用户的服务
/指示邮件文件夹的路径,用户可以在其中 在mail.jcfg文件中指定首选项
:指定另一个用户名的别名(如果不是 相同)
>;将电子邮件转发给外部邮件传递代理,或 另一个邮件服务器(如果指定了邮件地址);如果最后一个 参数是SHA256哈希密码短语,用户可以中继消息 使用邮件地址作为用户名
.将消息传递给phen插件;邮件插件本身 用确认回音回复邮件
Note: the IMAP server only works with Evolution so far. Thunderbird and Geary still can’t retrieve messages correctly.
用户配置
引用/[user-identity]/mail/mail.jcfg:
{ "passphrase": "sha256-passphrase", "pop3pwd": "obscured-passphrase", "external-MDA": "command parameters", "authorization": "admin sign allowing the external-MDA command", "delivery": "path-to-custom-folder", # default: mail-foder/delivery "filters": "path-to-custom-file" # default: mail-foder/filters.jcfg }
密码短语用于SMTP和IMAP身份验证及其哈希 可以使用phen的shell命令sha256:
admin:iYPM7:/[iYPM7]$ sha256 Type in your pass phrase: 08fc92f4ad885e06491aa5b19435849eb62232a056dd840a53fee62a5507b654
POP实现需要密码短语的未加密存储, 因此,为了避免使用明文,可以使用shell命令obscure:
admin:iYPM7:/[iYPM7]$ obscure Type in your pass phrase: KTgyfDNrNH0kbCkCKgMtAi4D
不属于admin帐户的标识必须具有admin 使用主机系统资源的授权,如使用和 外部mda或执行代码筛选器。
过滤器配置文件示例:
{ "filters": [ {"type": "py", "code": "file:test-filter.py"}, {"type": "match", "content": "[3ug-l]", "action": "accept:Lists/3ug-l"} ] }
代码过滤器示例:
try:cnt=int(msg["Subject"].split()[-1])ifcnt%2:accept("odd")accept("even")except:pass
取数器配置
示例/[user-identity]/system/config/mail-fetcher.jcfg:
{ "mail-folders": { "mail": "/[user-identity]/mail" }, "accounts": [ { "server": "imap.example.com", "protocol": "imap", # imap / imaps "username": "alice", "passphrase": "KTgyfDNrNH0kbCkCKgMtAi4D", "period": "5 min", "first-time": "download-all", # default is "ignore-all" "boxes": [ {"Inbox": "filter"}, "SomeList", # same as {"SomeList": "filter"} {"SomeOtherList": "accept:mail:Lists/SomeOther"}, {"Spam": "delete"} ] } ] }
上面的mail-folders部分是默认的,如果 不变。
Note: protocols pop / pops not available yet.
立即待办事项列表
- 更好的用户文档(当前未描述某些功能)
- 开发人员文档
- 通过POP获取
- 通过IMAP连续提取(不要断开连接,进入空闲状态)
- python3支持
- 测试
- 优化(这里有很大的改进空间)
未来计划
- 使用phen内部消息传递机制的网关
- 在phen.db数据库中长期存储。
- 使用woosh进行关键字搜索。
- 与Notmuch互动。