1

我正在使用Znarkus Postmark PHP类来处理邮件程序。

回复后:

{"status":false,"validator":null,"response":true,"errors":[],"exception":"exception 'InvalidArgumentException' with message 'Reply To address \"1\" is invalid' in \/var\/www\/stm\/vendor\/znarkus\/postmark\/src\/Postmark\/Mail.php:276\nStack trace:\n#0 \/var\/www\/stm\/lib\/croscon\/stm\/Email.php(59): Postmark\\Mail->replyTo(true, 'customerservice...')\n#1 \/var\/www\/stm\/lib\/croscon\/stm\/Email.php(119): croscon\\stm\\Email->sendMeWithKnownEmail('contactUs', 'info@muserk.com', ' has contacted ...', Array, 'customerservice...', 'customerservice...', true)\n#2 \/var\/www\/stm\/services\/Contact.php(32): croscon\\stm\\Email->contactUs(NULL, NULL, NULL, false)\n#3 [internal function]: App\\Service\\Contact->sendMethod()\n#4 \/var\/www\/stm\/vendor\/croscon\/strongpanda\/StrongPanda\/Service.php(89): call_user_func_array(Array, Array)\n#5 \/var\/www\/stm\/vendor\/croscon\/strongpanda\/StrongPanda\/Service\/Translator\/JSONRPC.php(117): StrongPanda\\Service->run('send')\n#6 \/var\/www\/stm\/vendor\/croscon\/strongpanda\/StrongPanda\/FrontController.php(99): StrongPanda\\Service\\Translator\\JSONRPC->CallService(Object(App\\Service\\Contact), 'send', Array)\n#7 \/var\/www\/stm\/public\/index.php(10): StrongPanda\\FrontController->__construct()\n#8 {main}","messages":[]}

最近我的自定义验证器正在工作,但现在POST请求状态出现 500 内部服务器错误。

{"status":false,"validator":null,"response":true,"errors":[],"exception":"exception 'InvalidArgumentException' with message 'Reply To address \"1\" is invalid' in \/var\/www\/stm\/vendor\/znarkus\/postmark\/src\/Postmark\/Mail.php:276\nStack trace:\n#0 \/var\/www\/stm\/lib\/croscon\/stm\/Email.php(59): Postmark\\Mail->replyTo(true, 'customerservice...')\n#1 \/var\/www\/stm\/lib\/croscon\/stm\/Email.php(119): croscon\\stm\\Email->sendMeWithKnownEmail('contactUs', 'info@muserk.com', ' has contacted ...', Array, 'customerservice...', 'customerservice...', true)\n#2 \/var\/www\/stm\/services\/Contact.php(32): croscon\\stm\\Email->contactUs(NULL)\n#3 [internal function]: App\\Service\\Contact->sendMethod()\n#4 \/var\/www\/stm\/vendor\/croscon\/strongpanda\/StrongPanda\/Service.php(89): call_user_func_array(Array, Array)\n#5 \/var\/www\/stm\/vendor\/croscon\/strongpanda\/StrongPanda\/Service\/Translator\/JSONRPC.php(117): StrongPanda\\Service->run('send')\n#6 \/var\/www\/stm\/vendor\/croscon\/strongpanda\/StrongPanda\/FrontController.php(99): StrongPanda\\Service\\Translator\\JSONRPC->CallService(Object(App\\Service\\Contact), 'send', Array)\n#7 \/var\/www\/stm\/public\/index.php(10): StrongPanda\\FrontController->__construct()\n#8 {main}","messages":[]}

我发现它在电子邮件验证器片段中失败:

public function &replyTo($address, $name = null)
    {

        if (!$this->_validateAddress($address)) {
          throw new InvalidArgumentException("Reply To address \"{$address}\" is invalid");
        }

        $this->_replyTo = array('address' => $address, 'name' => $name);
        return $this;
    }




   /**
     * Validates an e-mail address
     * @param $email
     * @return bool
     */
    private function _validateAddress($email)
    {
        // http://php.net/manual/en/function.filter-var.php
        // return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
        // filter_var proved to be unworthy (passed foo..bar@domain.com as valid),
        // and was therefore replace with
        $regex = "/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i";
        // from http://fightingforalostcause.net/misc/2006/compare-email-regex.php
        return preg_match($regex, $email) === 1;
    }

我很有信心我regex以前工作过。但是后来,我所有的邮件都开始失败了。

4

0 回答 0