使用Exim中的管道进行邮件路由 [英] Mail Routing using pipe in Exim

查看:108
本文介绍了使用Exim中的管道进行邮件路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找发送电子邮件到多个目的地的方法,即一个发送给用户指定的电子邮件地址,另一个发送给php脚本.在网上冲浪时,我得出的结论是,我必须在路由器中使用管道并传输邮件代理的配置,即在我的情况下为Exim.我尝试过,但未能在我的Exim配置中嵌入管道传输.服务器导致管道传输失败.需要帮助以解决此问题. 我将exim.cnf文件修改为:

I was looking for sending email to multiple destinations i.e One to the user specified email address and other to a php script. Surfing over the web, I concluded that I have to use pipe in routers and transfer configurations of my mailing agent i.e Exim in my case. I tried but failed to embed pipe transfer in my Exim configurations. Server results in failing pipe transfer. Need help in getting this issue fixed. I modified my exim.cnf file as:

############ ROUTERS
system_aliases:
driver = accept 
domains = **.**.**.**(my Domain) 
transport = use_pipe

############ TRANSPORT
use_pipe:
debug_print = "Using Pipe Transport"
driver = pipe
command = /etc/script.php
return_path_add
delivery_date_add
envelope_to_add
return_output

其中script.php是我要发送文件的第二个目标. 这是日志:

where script.php is the second destination where I want to send the file. Here are the Logs:

 3402   uid=3000 gid=3000 pid=3402
 3402   auxiliary group list: 3000
 3402   home=NULL current=/
 3402 set_process_info:  3402 delivering 1ZTPOU-0000sn-JB to abc using use_pipe
 3402 Using Pipe Transport
 3402 use_pipe transport entered
 3402 direct command:
 3402   argv[0] = /etc/testScript.php
 3402 direct command after expansion:
 3402   argv[0] = /etc/testScript.php
 3402 Writing message to pipe
 3402 writing data block fd=10 size=44 timeout=3600
 3402 writing data block fd=10 size=2048 timeout=3600
 3402 writing data block fd=10 size=1 timeout=3600
 3404 set_process_info:  3404 reading output from |/etc/testScript.php
 3402 use_pipe transport yielded 2
 3402 search_tidyup called
 3399 use_pipe transport returned FAIL for abc@myDomain
 3399 post-process abc@myDomain (2)
 3399 LOG: MAIN
 3399   ** abc@myDomain R=system_aliases T=use_pipe: Child process of use_pipe transport returned 127 (could mean unable to exec or command does not exist) from command: /etc/testScript.php

* testScript存在于日志中指定的确切位置.

*testScript is present at the exact location specified in logs.

推荐答案

在路由器部分,我编写了自己的自定义路由器,它将电子邮件发送到所需的php脚本.在运输部分中,编写了我自己的自定义运输,该运输将确保使用curl传递到所需的脚本.保持路由器配置中的system_aliases部分不变,但将驱动程序从accept更改为redirect.在我的/etc/exim.cnf文件中写入以下配置:

In routers section I wrote my own custom router that will deliver email to my desired php script. In transport section wrote my own custom transport that will ensure delivery to the desired script using curl. Kept the system_aliases section in Routers configuration as it is but changed driver from accept to redirect.Wrote the following configurations in my /etc/exim.cnf file:

############ROUTERS
runscript:
        driver = accept
        transport = run_script
        unseen
        no_expn
        no_verify
############TRANSPORT
run_script:
     debug_print = "T: run_script for $local_part@$domain"
     driver = pipe
     command = /home/bin/curl http://my.domain.com/mailTest.php --data-urlencode $original_local_part@$original_domain

mailTest.php是我的php脚本

mailTest.php was my php script

这篇关于使用Exim中的管道进行邮件路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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