如何通过MailChimp 3.0 API发送电子邮件? [英] How to send email through MailChimp 3.0 api?

查看:675
本文介绍了如何通过MailChimp 3.0 API发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过PHP中的mailchimp api 3.0版发送电子邮件,但我没有运气.这是我的代码:

I'm trying to send email through mailchimp api version 3.0 in php, but i have no luck. This is my code:

$postString = '{
        "message": {
            "html": "this is the emails html content",
            "text": "this is the emails text content",
            "subject": "this is the subject",
            "from_email": "xxx@dyyy.sk",
            "from_name": "John",
            "to_email": "aaa.bbb@gmail.com",
            "to_name": "Anton",
            "track_opens": false,
            "track_clicks": false
        }}';

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->api_endpoint);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
        curl_setopt($ch, CURLOPT_USERPWD, 'drewm:'.$this->api_key);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/vnd.api+json', 'Content-Type: application/vnd.api+json'));
        curl_setopt($ch, CURLOPT_USERAGENT, 'DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)');
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

        $result = curl_exec($ch);

        echo $result;

我在做什么错了?

推荐答案

您无法像使用v1一样从API v3发送随机电子邮件.现在,您只能按照LamaDelRay的说明在MailChimp中发送先前创建的广告系列.

You cannot send a random email from API v3 like you probably did with v1. Now you can only send a previously created campaign in MailChimp as stated by LamaDelRay.

这篇关于如何通过MailChimp 3.0 API发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆