dtu1747 2011-11-26 14:29
浏览 46
已采纳

如果使用管道到php脚本方法传递电子邮件失败时发生某些事情,如何更改MTA返回错误

I using WHM/Cpanel

Im using the pipe technique to forward the income emails to php script and everthing fine. but while working if any error happend while piping the following msg for example will returned to the email sender

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

Please note that I make the pipe from Cpanel for the email support@somecompany.net|/home/someuser/public_htmk/pipe.php

the php script below does not have error :) but I define the path of the file to make an error because it should be public_html not public_htmk but I make this error to show you the error message which returned to the email sender.

So is there anyway to control of this returned message or disable it . for example change it or not to send the physical address of the php file that we are running to pipe the email atleast?

BTW I'm using

WHM/Cpanel Dovecot PHP

and this is a sample of the pipe script (this script does not have any error)

#!/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 . '"');

I'm looking to customize or disable the return msg which returned to the email sender when some error happened when piping email to a script.

any ideas?

  • 写回答

3条回答 默认 最新

  • dtpxi88884 2011-12-05 19:23
    关注

    If you do not insist on putting troublesome code in the pipe definition, you can use the shell script wrapper around your php script, something like

    #!/bin/bash
    /home/someuser/public_htmk/pipe.php >&/home/someuser/pipe.errors.log || true
    

    and use it in your pipe definition.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器