为什么 Mandrill 电子邮件不是从开发服务器(本地主机)发送的?

Why Mandrill emails are not sent from development server(localhost)?

我正在使用 Mandrill API 发送电子邮件。

我已经注册了我的发送域并在 Mandrill 设置页面中正确设置了我的 DKIM 和 SPF 记录。

以下是我用于发送电子邮件的代码:

$template_name = "Test_Schedule_Reminder";
$to_email = "debesh@debeshnayak.com";
$to_name = "Test Email";

$from_email = "contact@debeshnayak.com";
$from_name = "Debesh Nayak";

require_once 'mandrill-api-php/src/Mandrill.php'; //Not required with Composer
try {
    $mandrill = new Mandrill('my-mandrill-api-key');
    $message = array(
            'html' => $html_email_template,
            'subject' => $email_title,
            'from_email' => $from_email,
            'from_name' => $from_name,
            'to' => array(
                    array(
                            'email' => $to_email,
                            'name' => $to_name,
                            'type' => 'to'
                    )
            ),
            'important' => true,
            'track_opens' => true,
            'track_clicks' => true,
            'inline_css' => true,
            'metadata' => array('website' => 'www.debeshnayak.com'),
    );
    $async = false;
    $ip_pool = null;
    $send_at = $utc_class_time;
    $result = $mandrill->messages->send($message, $async, $ip_pool, $send_at);
    print_r($result);
} catch(Mandrill_Error $e) {
    // Mandrill errors are thrown as exceptions
    echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
    // A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
    throw $e;
}

我可以在从生产服务器发送电子邮件时发送电子邮件。

但是当我尝试从本地主机发送电子邮件时出现以下错误:

Mandrill_HttpError - API call to messages/send failed: SSL certificate problem: unable to get local issuer certificate

那么如何在使用 Mandrill 测试来自本地主机的邮件时避免此 SSL 证书问题 API。

我在 Mandrill.php 库文件的 call() 函数中添加了以下两行:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

现在我可以使用 Mandrill API 从我的 localhost 发送电子邮件了。

检查 Mandrill 的库文件并搜索 cURL 发送电子邮件的调用。检查此 cURL 的 "CURLOPT_SSL_VERIFYPEER" 参数。将值设置为 false。应该对你有帮助。