Sample code for 30+ languages & platforms
Unicode C++ 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 Unicode C++ Downloads

Unicode C++
#include <CkEmailW.h>
#include <CkJsonObjectW.h>
#include <CkHttpW.h>
#include <CkHttpResponseW.h>

void ChilkatSample(void)
    {
    bool success = false;

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

    CkEmailW email;
    email.put_From(L"Workshop team <events@example.com>");
    success = email.AddTo(L"Alex Rivera",L"alex@example.net");
    if (success != true) {
        wprintf(L"%s\n",email.lastErrorText());
        return;
    }

    email.put_Subject(L"Workshop registration");
    email.put_Body(L"Your workshop registration is confirmed.");
    CkJsonObjectW request;
    request.UpdateString(L"email",email.getMime());
    request.UpdateString(L"options",L"short");
    CkHttpW http;
    http.put_RequireSslCertVerify(true);
    CkHttpResponseW resp;
    success = http.HttpJson(L"POST",L"https://spamcheck.postmarkapp.com/filter",request,L"application/json",resp);
    if ((success != true) || (resp.get_StatusCode() != 200)) {
        wprintf(L"SpamCheck request failed. HTTP %d\n",resp.get_StatusCode());
        return;
    }

    CkJsonObjectW result;
    success = result.Load(resp.bodyStr());
    if (success != true) {
        wprintf(L"%s\n",result.lastErrorText());
        return;
    }

    if (result.BoolOf(L"success") != true) {
        wprintf(L"%s\n",result.stringOf(L"message"));
        return;
    }

    wprintf(L"SpamAssassin score: %s\n",result.stringOf(L"score"));
    }