Sample code for 30+ languages & platforms
Node.js Requires Chilkat v11.0.0+

Request a SpamAssassin score for a sample email

See more Email Object Examples

Submit a synthetic message to Postmark’s SpamCheck endpoint. The service receives the complete MIME you provide. Request a short result and check both the HTTP status and the API success field before reading the numeric score. SpamCheck API documentation.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    //  Assumes Chilkat is unlocked. See Global Unlock Sample.

    var email = new chilkat.Email();
    email.From = "Workshop team <events@example.com>";
    success = email.AddTo("Alex Rivera","alex@example.net");
    if (success !== true) {
        console.log(email.LastErrorText);
        return;
    }

    email.Subject = "Workshop registration";
    email.Body = "Your workshop registration is confirmed.";
    var request = new chilkat.JsonObject();
    request.UpdateString("email",email.GetMime());
    request.UpdateString("options","short");
    var http = new chilkat.Http();
    http.RequireSslCertVerify = true;
    var resp = new chilkat.HttpResponse();
    success = http.HttpJson("POST","https://spamcheck.postmarkapp.com/filter",request,"application/json",resp);
    if ((success !== true) || (resp.StatusCode !== 200)) {
        console.log("SpamCheck request failed. HTTP " + resp.StatusCode);
        return;
    }

    var result = new chilkat.JsonObject();
    success = result.Load(resp.BodyStr);
    if (success !== true) {
        console.log(result.LastErrorText);
        return;
    }

    if (result.BoolOf("success") !== true) {
        console.log(result.StringOf("message"));
        return;
    }

    console.log("SpamAssassin score: " + result.StringOf("score"));

}

chilkatExample();