Postfix消息收到钩子 [英] Postfix message received hook

查看:111
本文介绍了Postfix消息收到钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Web应用程序,该应用程序需要接收到用户内部电子邮件地址的电子邮件,让管理员批准它们,然后转发到相应用户的外部邮箱.

I am writing an web-application which needs to receive e-mail messages to users' internal email addresses, let administrators approve them, and then forward to corresponding user's external mailbox.

我已经安装并配置了用于消息接收任务的后缀.它使用虚拟电子邮件地址以及存储用户电子邮件地址的现有数据库.本地电子邮件存储为maildir,我使用后缀的虚拟MDA.

I have installed and configured postfix for message receiving task. It uses virtual e-mail addresses, and my existing database where user email addresses are stored. Local email storage is maildir and I use postfix's virtual MDA.

基本上,我想在每次收到新消息以及针对该用户时执行脚本(maildir消息ID也将非常有帮助).然后,我可以从python代码中读取消息(python有用于maildir消息框的模块)并将其插入数据库中. 我可以想到三种方法:

Basically, I would like to execute a script every time a new message is received, and for which user (maildir message id would be very helpful too). Then I could read the message from python code (python had a module for maildir messageboxes) and insert it in database. I can think of three ways to do this:

  • 重复用户maildirs并检查 如果有任何新消息,但这对于大量用户而言将是无效的.
  • 使用dbmail,然后检查数据库中是否有任何新消息(这会更快,但是我必须从头开始配置所有内容).此外,无法使用现有的用户数据表.
  • 围绕maildrop/virtual编写包装器,以将消息也保存在db和maildir中,但是我需要一种方法来检查接收到的消息是否有效,并由 real MDA成功保存.
  • iterate user maildirs and check if there are any new messages, but it would be ineffective for large number of users.
  • use dbmail and then check if there are any new messages in database (this would be quicker, but I'd have to configure everything from scratch). Besides, existing user data tables cannot be used.
  • write a wrapper around maildrop/virtual to save message in db and in maildir as well, but I'd need a way to check if received message is valid and successfully saved by the real MDA.

任何建议表示赞赏!

推荐答案

为回答我自己的问题,我在管道中使用了X标志设置了postfix content_filter,并手动处理接收地址和消息.由于我不需要访问maildir中的消息,因此这种方法对我来说很好.

In response to my own question, I used postfix content_filter with X flag set in pipe and process receiving address and message manually. Since I didn't need to access messages in maildir, this approach works fine for me.

这篇关于Postfix消息收到钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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