MailChimp send email API not working

时间:2016-10-19 15:50:50

标签: php email curl mailchimp mailchimp-api-v3.0

I am using the below code to send email with MailChimp API key. But it returns the below error

Curl error: Couldn't resolve host 'us14.sts.mailchimp.com'

Here is the code that I am using,

$apikey = '*********-us14';
$to_emails = array('******@gmail.com');
$to_names = array('You', 'Your Mom');
$message = array(
    'html' => 'Yo, this is the <b>html</b> portion',
    'text' => 'Yo, this is the *text* portion',
    'subject' => 'This is the subject',
    'from_name' => 'Me!',
    'from_email' => 'verifed@example.com',
    'to_email' => $to_emails,
    'to_name' => $to_names
);

$tags = array('WelcomeEmail');
$params = array(
    'apikey' => $apikey,
    'message' => $message,
    'track_opens' => true,
    'track_clicks' => false,
    'tags' => $tags
);

$url = "http://us14.sts.mailchimp.com/1.0/SendEmail";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url.'?'.http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);
if ($result === false) {
    echo 'Curl error: ' . curl_error($ch);
} else {
    echo 'Operation completed without any errors';
}

curl_close ($ch);

0 个答案:

没有答案