Postfix消息收到钩子

编程入门 行业动态 更新时间:2024-10-22 07:51:59
本文介绍了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消息收到钩子

本文发布于:2023-10-13 00:03:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486245.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:钩子   消息   Postfix

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!