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

Delphi DLL
var
success: Boolean;
email: HCkEmail;
request: HCkJsonObject;
http: HCkHttp;
resp: HCkHttpResponse;
result: HCkJsonObject;

begin
success := False;

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

email := CkEmail_Create();
CkEmail_putFrom(email,'Workshop team <events@example.com>');
success := CkEmail_AddTo(email,'Alex Rivera','alex@example.net');
if (success <> True) then
  begin
    Memo1.Lines.Add(CkEmail__lastErrorText(email));
    Exit;
  end;
CkEmail_putSubject(email,'Workshop registration');
CkEmail_putBody(email,'Your workshop registration is confirmed.');
request := CkJsonObject_Create();
CkJsonObject_UpdateString(request,'email',CkEmail__getMime(email));
CkJsonObject_UpdateString(request,'options','short');
http := CkHttp_Create();
CkHttp_putRequireSslCertVerify(http,True);
resp := CkHttpResponse_Create();
success := CkHttp_HttpJson(http,'POST','https://spamcheck.postmarkapp.com/filter',request,'application/json',resp);
if ((success <> True) or (CkHttpResponse_getStatusCode(resp) <> 200)) then
  begin
    Memo1.Lines.Add('SpamCheck request failed. HTTP ' + IntToStr(CkHttpResponse_getStatusCode(resp)));
    Exit;
  end;
result := CkJsonObject_Create();
success := CkJsonObject_Load(result,CkHttpResponse__bodyStr(resp));
if (success <> True) then
  begin
    Memo1.Lines.Add(CkJsonObject__lastErrorText(result));
    Exit;
  end;
if (CkJsonObject_BoolOf(result,'success') <> True) then
  begin
    Memo1.Lines.Add(CkJsonObject__stringOf(result,'message'));
    Exit;
  end;
Memo1.Lines.Add('SpamAssassin score: ' + CkJsonObject__stringOf(result,'score'));

CkEmail_Dispose(email);
CkJsonObject_Dispose(request);
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
CkJsonObject_Dispose(result);