Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Unobfuscate a Spammy Email
See more Email Object Examples
Demonstrates the Chilkat Email.UnSpamify method, which unobfuscates an email by undoing common spammer tricks — it removes comments from HTML bodies and unobfuscates hyperlinked URLs. This example cleans an HTML body whose link was broken up by an inserted comment.
Background: Spammers deliberately scramble HTML to slip past filters — inserting empty comments in the middle of words or URLs (
exa<!--x-->mple.com), or otherwise obfuscating links — so the message renders normally to a human but confuses naive keyword matching. UnSpamify reverses those tricks, producing a normalized body that is easier to analyze, classify, or scan for the real destination of its links.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Email;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
email: TEmail;
cleaned: string;
begin
// Demonstrates the UnSpamify method, which unobfuscates an email by undoing common spammer
// tricks: it removes comments from HTML bodies and unobfuscates hyperlinked URLs.
email := TEmail.Create;
email.Subject := 'UnSpamify example';
// An HTML body with an obfuscating comment inserted into a hyperlink.
email.SetHtmlBody('<html><body>Visit <a href="http://exa<!--x-->mple.com">our site</a>.</body></html>');
// Undo the obfuscation.
email.UnSpamify();
cleaned := email.GetHtmlBody();
WriteLn(cleaned);
email.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.