cPanel 电子邮件过滤器管道到未执行的程序

问题描述 投票:0回答:2

我无法获取特定地址的电子邮件过滤器来正确执行其通过管道传输到的脚本,什么也没有发生。没有日志消息,没有错误消息 - 我不知道发生了什么以及为什么它不执行:

过滤器(来自:/home/myUser/ect/myDomain/register/filter):

headers charset "UTF-8"

if not first_delivery and error_message then finish endif

#Bounced Registrations
if
 $header_subject: contains "Message Delivery Failure"
then
 pipe "| php -q /home/myUser/dev/scripts/email/bouncedEmail.php"
endif

我尝试了很多组合:

 pipe "| /home/myUser/dev/scripts/email/bouncedEmail.php"
 pipe "/home/myUser/dev/scripts/email/bouncedEmail.php"
 pipe "|php -q /home/myUser/dev/scripts/email/bouncedEmail.php"
 pipe "/usr/local/bin/php -q /home/myUser/dev/scripts/email/bouncedEmail.php"
 pipe "| /usr/local/bin/php -q /home/myUser/dev/scripts/email/bouncedEmail.php"

但是当我将保存的退回电子邮件提供给脚本时,脚本可以从命令干净地运行 - 下面捕获错误的电子邮件地址并将“Script Ran”打印到日志文件:

[> email]$ cat badEmail.msg | php -q bouncedEmail.php

脚本,设置权限:0755

#!/usr/local/bin/php -q
<?php
ini_set("log_errors", 1);
ini_set("error_log", "bouncedEmails.log");
include '/home/myUser/dev/scripts/includes.php' ;

error_log("Script ran") ;

// read from stdin
$fd = fopen("php://stdin", "r") ;
$email = "" ;
while (!feof($fd)) {
  $email .= fread($fd, 1024);
}
fclose($fd);

// handle email
$lines = explode("\n", $email);

// empty vars
$splittingheaders = true;

for ($i=0; $i < count($lines); $i++){
  //if ($splittingheaders) {
    // this is a header
    $headers .= $lines[$i]."\n";

    // look out for special headers
    if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
        list($fName,$fAddy) = explode("<",$matches[1]) ;
        $fAddy = str_replace(">","",$fAddy) ;
        //error_log("FROM: " .$lines[$i],0) ;
        
    }
    if (preg_match("/^To: (.*)/", $lines[$i], $matches)) {
        list($tName,$tAddy) = explode("<",$matches[1]) ;
        $tAddy = str_replace(">","",$tAddy) ;
        error_log("Bad Email: $tAddy",0) ;
        writeDB($tAddy) ;
    }
    if (preg_match("/^REFID: (.*)/",$lines[$i],$matches)) {
        $uid = $matches[1] ;
    }
  //}

  if (trim($lines[$i])=="") {
    // empty line, header section has ended
    $splittingheaders = false;
  }
}


// update any DB records with matched email addresses
function writeDB($to) {
  $query = "UPDATE userTable SET user_email='',user_emailVerify=0 WHERE user_email=?" ;
  list($upCount,$upError) = dbUpdate($query,array($to)) ;
}

unset($pdo) ;
?>

那么我做错了什么导致电子邮件过滤器脚本无法执行?

php email parsing filter cpanel
2个回答
0
投票

我已经修复了它,但我不知道为什么我的原始脚本不起作用。

即使已使用

#!/usr/local/bin/php -q

 将文件设置为可执行文件,
chmod 0755 bouncedEmails.php

也未被识别

为了让它发挥作用,我在

pipe to a program
中添加了:
php -q /home/myUser/dev/scripts/email/bouncedEmails.php


0
投票

让电子邮件过滤器管道编程工作的 3 个步骤

  1. script.php:chmod 755
  2. 管道中程序的路径: | php -q public_html/script.php
  3. 在 script.php 顶部的 php 开始标记之前添加 #!/usr/local/bin/php -q
© www.soinside.com 2019 - 2024. All rights reserved.