将 exim4 收取的邮件,用 router 和 transport 转给脚本处理 piping - debian
环境:debian 11, exim4, php8.1, osticket-1.17
需求:用exim接收邮件,将邮件通过 piping 交给 osticket 的 php 脚本处理
过程:
- 新增一条 router 配置文件,如 /etc/exim4/conf.d/router/050_exim4-config_osticket
050_exim4-config_osticket 内容如下。意思要将support@localdomain的邮件交给osticket_transport受理
osticket_router: driver = accept local_parts = support transport = osticket_transport
- 新增 osticket_transport 的配置文件,如 /etc/exim4/conf.d/transport/25_exim4-config_osticket_pipe
25_exim4-config_osticket_pipe 内容如下。意思是将邮件交给 /var/www/public_html/api/pipe.php 处理
osticket_transport: driver = pipe command = /usr/bin/php8.1 /var/www/public_html/api/pipe.php
- 将新增的配置文件内容添加到模板中,update-exim4.conf.template -r
- 更新exim的配置,update-exim4.conf
- 重载 systemctl reload exim4 的服务
- 可通过如 exim4 -bt support@localdomain 的命令来检查新设置的 router 和 transport 是否生效
参考:
- https://docs.osticket.com/en/latest/Getting%20Started/Email%20Piping.html
- https://serverfault.com/questions/565973/make-exim-deliver-local-mail-externally
- https://manpages.debian.org/testing/exim4-config/update-exim4.conf.template.8.en.html
- https://www.howtogeek.com/devops/how-to-route-incoming-email-to-your-application-with-exim/
- https://geekthis.net/post/exim-process-mail-script/