Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mandrill PHP无法获取本地颁发者SSL证书_Php_Mandrill - Fatal编程技术网

Mandrill PHP无法获取本地颁发者SSL证书

Mandrill PHP无法获取本地颁发者SSL证书,php,mandrill,Php,Mandrill,我已经在我的Windows Apache服务器上安装了Mandrill PHP API。尝试使用下面的代码发送电子邮件时,我收到错误: Mandrill_HttpError-对消息/发送模板的API调用失败:SSL证书问题:无法获取本地颁发者证书 我不清楚Mandrill如何连接到我的本地颁发者证书。我的web服务器确实具有有效的证书,并且可以成功显示HTTPS页面 有什么想法吗 $mandrill = new Mandrill('MyMandrillAPIKey');

我已经在我的Windows Apache服务器上安装了Mandrill PHP API。尝试使用下面的代码发送电子邮件时,我收到错误:

Mandrill_HttpError-对消息/发送模板的API调用失败:SSL证书问题:无法获取本地颁发者证书

我不清楚Mandrill如何连接到我的本地颁发者证书。我的web服务器确实具有有效的证书,并且可以成功显示HTTPS页面

有什么想法吗

        $mandrill = new Mandrill('MyMandrillAPIKey');

        $message = array(
            'subject' => 'Test message',
            'from_email' => 'MyEmailAddress',
            'html' => '<p>this is a test message with Mandrill\'s PHP wrapper!.</p>',
            'to' => array(array('email' => 'MyEmailAddress', 'name' => 'David Splat')),
            'merge_vars' => array(array(
                'rcpt' => 'MyEmailAddress',
                'vars' =>
                array(
                    array(
                        'name' => 'FIRSTNAME',
                        'content' => $fName),
                    array(
                        'name' => 'LASTNAME',
                        'content' => $lName)
            ))));

        $template_name = 'MyTemplateName';

        $template_content = array(
            array(
                'name' => 'main',
                'content' => 'Hi *|FIRSTNAME|* *|LASTNAME|*, thanks for signing up.'),
            array(
                'name' => 'footer',
                'content' => 'Copyright 2014.')

        );

        print_r($mandrill->messages->sendTemplate($template_name, $template_content, $message));

    } catch(Mandrill_Error $e) {
        // Mandrill errors are thrown as exceptions
        echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
        throw $e;
    }
$mandrill=新的mandrill('MyMandrillAPIKey');
$message=数组(
“主题”=>“测试消息”,
'来自电子邮件'=>'我的邮件地址',
“html'=>”这是一条带有Mandrill的PHP包装器的测试消息。

, '到'=>数组(数组('email'=>'MyEmailAddress','name'=>'davidsplat')), “合并变量”=>数组(数组( “rcpt'=>“MyEmailAddress”, 'vars'=> 排列( 排列( 'name'=>'FIRSTNAME', “内容”=>$fName), 排列( 'name'=>'LASTNAME', “内容”=>$lName) )))); $template_name='MyTemplateName'; $template\u content=array( 排列( 'name'=>'main', “content'=>”您好*| FIRSTNAME |**| LASTNAME |*,谢谢您的注册。“), 排列( “名称”=>“页脚”, “内容”=>“版权所有2014”。) ); 打印($mandrill->messages->sendTemplate($template\u name,$template\u content,$message)); }捕获(Mandrill_错误$e){ //Mandrill错误作为异常抛出 echo“发生了一个mandrill错误:”。get_类($e)。“-”。$e->getMessage(); 扔$e; }
这是一个解决我问题的更改。在Mandrill.php中,在调用curl_init()之后添加以下两行:


这个方法是由

中的一个答案建议的,您不需要关闭curl SSL选项,相反,您可以从下载cacert.pem文件,然后将其包含在php.ini文件中
curl.cainfo=“/exact/location/to/cacert.pem”

或者简单地更改Mandrill.php文件中的行以使用它,如下所示

curl_setopt ($this->ch, CURLOPT_SSL_VERIFYPEER, TRUE); 
curl_setopt ($this->ch, CURLOPT_CAINFO, __DIR__ . "/cacert.pem")

这实际上完全关闭了SSL,有点危险。使用SSL时可以找到正确的解决方案,这是有原因的。你不应该把它关掉。帮了我一个windows用户。我选择了第一种选择。请注意,php.ini中可能不存在“curl.cainfo”选项,添加该选项即可。
curl_setopt ($this->ch, CURLOPT_SSL_VERIFYPEER, TRUE); 
curl_setopt ($this->ch, CURLOPT_CAINFO, __DIR__ . "/cacert.pem")