【问题标题】:Mandrill PHP unable to get local issuer SSL certificateMandrill PHP 无法获取本地颁发者 SSL 证书
【发布时间】:2015-01-05 19:53:21
【问题描述】:

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

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

我不清楚 Mandrill 如何连接到我的本地颁发者证书。我的网络服务器确实有一个有效的证书,并且可以成功显示 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;
    }

【问题讨论】:

    标签: php mandrill


    【解决方案1】:

    这是一个解决了我的问题的更改。在 Mandrill.php 中,在 curl_init() 调用之后添加这两行:

    curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
    

    error in send email using Mandrill (php) 的其中一个答案建议了这种方法

    【讨论】:

    【解决方案2】:

    您无需关闭 curl SSL 选项,而是可以从 http://curl.haxx.se/docs/caextract.html 下载 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")
    

    link to the post http://tutewall.com/ssl-certificate-problem-unable-to-get-local-issuer-certificate/

    【讨论】:

    • 帮我救了一个 Windows 用户。我选择了第一个选项。请注意,选项“curl.cainfo”可能在 php.ini 中不存在,无论如何添加它就可以了。
    猜你喜欢
    • 2017-08-31
    • 2016-07-06
    • 2016-03-01
    • 1970-01-01
    • 2019-09-03
    相关资源
    最近更新 更多