error in send email using Mandrill (php)

和自甴很熟 提交于 2019-11-29 02:04:06

the error is indicating you don't have the required SSL cert installed locally to verify the SSL connection with Mandrill's API. You can get a bundle of certs through a package manager for your operating system, or you can download the bundle that's distributed with Mozilla: http://curl.haxx.se/docs/caextract.html and then store them locally.

Ricardo Martins

At this file: mandrill-api-php\src\Mandrill.php

At line 58 where initialize curl:

$this->ch = curl_init();

You need to add this two options to solve the problem:

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

Or you have this option to: HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK

After downloading cacert.pem from http://curl.haxx.se/docs/caextract.html and putting it on my server, I was able to fix this problem (while keeping everything secure) with the following:

$mandrill = new Mandrill(MANDRILL_API_KEY);

// Fix CA issue
curl_setopt($mandrill->ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($mandrill->ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($mandrill->ch, CURLOPT_CAINFO, 'PATH_TO/cacert.pem');

The curl property in the Mandrill class is public, so there is no need to add hacks to the library itself.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!