简体   繁体   中英

Trying to get Mandrill to send an email (codecademy exercise)

I'm trying to learn how to use the API's and I stumbled upon codecademy's course and I'm doing their Mandrill API course

// Create a function to log the response from the Mandrill API
function log(obj) {
    $('#response').text(JSON.stringify(obj));
}

// create a new instance of the Mandrill class with your API key
var m = new mandrill.Mandrill('sDJw??-3FK4r1h8aH2vckw');

// create a variable for the API call parameters
var params = {
    "message": {
        "from_email":"jack??@yahoo.com",
        "to":[{"email":"jack??@yahoo.com"}],
        "subject": "Sending a text email from the Mandrill API",
        "text": "I'm learning the Mandrill API at Codecademy."
    }
};

function sendTheMail() {
// Send the email!

    m.messages.send(params, function(res) {
        log(res);
    }, function(err) {
        log(err);
    });
}

The API key should work. The course allowed me to test in a previous exercise. I heard that Mandrill had changes recently that mentions

you must add SPF and DKIM records and verify ownership of your sending domains before you can send email through your account.

I'm wondering if I made mistake in the exercise or if the exercise dosen't work anymore because of the recent changes. I hope the link I showed you wasn't blocked .

Here is the error response:

[{"email":"jack??@yahoo.com","status":"rejected","_id":"?7ec118ce30044d493795081552c57d2","reject_reason":"unsigned"}]

There is nothing wrong in your code. I test it using my account api key and it works fine. This is something to do on Mandrill recent changes see here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM