javascript - How to send email using MailChimp API - Stack Overflow

I'm creating an app in nodejs to send an email using MailChimp. I've tried to use .0sendemai

I'm creating an app in nodejs to send an email using MailChimp. I've tried to use .0/sendemail.func.php but changed it to use 3.0 api because 1.0 seems to no longer work (big surprise). I've setup my app with

var apiKey = '<<apiKey>>',
        toEmail = '<<emailAddress>>',
        toNames = '<<myName>>',
        message = {
            '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': '',
            'to_email': toEmail,
            'to_name': toNames
        },
        tags = ['HelloWorld'],
        params = {
            'apikey': apiKey,
            'message': message,
            'track_opens': true,
            'track_clicks': false,
            'tags': tags
        },
        url = '.0/SendEmail';
needle.post(url, params, function(err, headers) {
    if (err) {
                console.error(err);
            }
            console.log(headers);
    }
});

I keep getting a 401 response (not authorized because I'm not sending the API key properly)

I have to use needle due to the constraints on the server.

I'm creating an app in nodejs to send an email using MailChimp. I've tried to use https://apidocs.mailchimp./sts/1.0/sendemail.func.php but changed it to use 3.0 api because 1.0 seems to no longer work (big surprise). I've setup my app with

var apiKey = '<<apiKey>>',
        toEmail = '<<emailAddress>>',
        toNames = '<<myName>>',
        message = {
            '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': '',
            'to_email': toEmail,
            'to_name': toNames
        },
        tags = ['HelloWorld'],
        params = {
            'apikey': apiKey,
            'message': message,
            'track_opens': true,
            'track_clicks': false,
            'tags': tags
        },
        url = 'https://us13.api.mailchimp./3.0/SendEmail';
needle.post(url, params, function(err, headers) {
    if (err) {
                console.error(err);
            }
            console.log(headers);
    }
});

I keep getting a 401 response (not authorized because I'm not sending the API key properly)

I have to use needle due to the constraints on the server.

Share Improve this question asked Apr 12, 2016 at 16:20 Tay MooreTay Moore 1371 gold badge1 silver badge12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

There is no "SendEmail" endpoint in API v3.0. MailChimp's STS was a pre-cursor to its Mandrill transactional service and may only still work for user accounts that have existing STS campaigns. No new STS campaigns can be created. If you have a monthly, paid MailChimp account, you should look into Mandrill. If not, I've had good luck with Mailgun.

You should use HTTP Basic authentication in MailChimp API 3.0.

needle.get('https://<dc>.api.mailchimp./3.0/<endpoint>', { username: 'anystring', password: 'your_apikey' },
  function(err, resp) {
      // your code here...
});

EDIT

@TooMuchPete is right, the SendMail endpoint is not valid in MailChimp API v3.0. I didn't notice that and I've edited my answer.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744026619a4545805.html

相关推荐

  • javascript - How to send email using MailChimp API - Stack Overflow

    I'm creating an app in nodejs to send an email using MailChimp. I've tried to use .0sendemai

    9天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信