我使用WHM/Cpanel
我使用管道技术将收入电子邮件转发到php脚本和一切都很好。但是在工作时,如果在管道中发生任何错误,例如以下MSG将返回给电子邮件发送者
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:
pipe to |/home/someuser/public_htmk/pipe.php
generated by support@somecompany.net
local delivery failed
请注意,我从Cpanel中为电子邮件创建了管道support@somecompany.net|/home/someuser/public_htmk/pipe.php
下面的php脚本没有错误:)但是我定义了文件的路径来产生错误,因为它应该是public_html而不是public_htmk,但是我使这个错误向您显示返回到电子邮件发件人的错误消息。
那么是否有办法控制这个返回的消息或禁用它呢?例如,更改它或不发送我们正在运行的PHP文件的物理地址,至少要发送电子邮件?
我用的是
交通和/Cpanel鸽舍PHP
,这是管道脚本的一个示例(该脚本没有任何错误)
#!/usr/local/bin/php -q
<?php
// read from stdin
$emg_stdf = fopen("php://stdin", "r");
$email = "";
while (!feof($emg_stdf))
{
$emg_orgemailmsg .= fread($emg_stdf, 1024);
}
fclose($emg_stdf);
mail('me@example.org','From my email pipe!','"' . $emg_orgemailmsg . '"');
我正在寻找自定义或禁用返回的msg返回到电子邮件发送者,当一些错误发生时,管道电子邮件到脚本。
任何想法?
如果您不坚持在管道定义中放入麻烦的代码,您可以在php
脚本周围使用shell脚本包装器,如
#!/bin/bash
/home/someuser/public_htmk/pipe.php >&/home/someuser/pipe.errors.log || true
这在某些情况下可能有助于解决您的问题,但是如果打开display_errors
,脚本中的错误消息可能会触发php脚本的负面响应,从而导致消息反弹。如果将其关闭,则不会输出或返回错误到MTA。
如果你有一个致命的错误,如解析错误,那么这可能没有帮助。
我不确定您是否有任何方法来控制返回消息的内容,但您可能会阻止它或尝试将消息返回给它。
它可能有助于把exit(0);
在电子邮件处理器的结束,以表明成功,所以如果你的脚本能够到达结束,它成功退出,并可能阻止MTA发送返回消息。
我不确定这是否有区别,但它可能有助于检查打开php://stdin是否成功,因为它可能会因为某些原因失败,如果你不能读取它,然后终止脚本。
要控制输出,如果检测到错误,请尝试回显消息或使用exit("status message");
在你得到的返回消息中,它是否包含PHP输出的错误消息或失败的原因?
我有同样的问题,我通过在根/etc文件夹中添加一个名为exim.conf的文件来解决它这对我很有效以下是该文件的内容希望它也能帮助到其他人!
# This transport is used for handling pipe deliveries generated by alias
# or .forward files. If the pipe generates any standard output, it is returned
# to the sender of the message as a delivery error. Set return_fail_output
# instead of return_output if you want this to happen only when the pipe fails
# to complete normally. You can set different transports for aliases and
# forwards if you want to - see the references to address_pipe in the directors
# section below.
address_pipe:
driver = pipe
return_fail_output
virtual_address_pipe:
driver = pipe
group = nobody
return_fail_output
user = "${lookup{$domain}lsearch* {/etc/virtual/domainowners}{$value}}"