Reputation: 244
I am using Mandrill API to send email.
I have register my send domain and set my DKIM and SPF record properly inside Mandrill Setting page.
Following is my code that is being used to send email:
$template_name = "Test_Schedule_Reminder";
$to_email = "[email protected]";
$to_name = "Test Email";
$from_email = "[email protected]";
$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;
}
I am able to send email when I am sending from my production server.
But when I am trying to send email from localhost I am getting the following error:
Mandrill_HttpError - API call to messages/send failed: SSL certificate problem: unable to get local issuer certificate
So how to avoid this SSL certificate problem when testing mail from localhost using Mandrill API.
Upvotes: 2
Views: 2285
Reputation: 965
Do check library files of Mandrill and search for cURL
call that sending out email. Check for "CURLOPT_SSL_VERIFYPEER"
parameter of this cURL. Set value to false
. It should help you.
Upvotes: 3
Reputation: 244
I have added the following two line inside call()
function of Mandrill.php
library file:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
And now I am able to send email from my localhost
using Mandrill API
.
Upvotes: 1