RemoveAnyHeader

From 40tude Dialog Wiki

Remove any single header

This is a OnBeforeSendingMessage event script. Using this script you can delete any single header (e.g. User-Agent) and its content from your emails and/or postings.

Tested successfully on 2.0.10.1


program OnBeforeSendingMessage;

const
// set the header you want to remove here, e.g. 'User-Agent'
    RemoveHeader='User-Agent';

// remove header from emails and/or postings
// set 'true' or 'false'
    RemoveFromEmails=true;
    RemoveFromNews=true;

procedure RemoveAnyHeader(Message:TStringlist;IsEmail:boolean);
var i:integer;
    s:string;
begin
  if ((IsEmail=true)  and (RemoveFromEmails=true)) or
     ((IsEmail=false) and (RemoveFromNews=true)) then
  begin
    s:=Message.text;
    while (Message.Strings[i]<>'') and (pos(RemoveHeader,Message.Strings[i])=0) do
    begin
      i:=i+1;
      if pos(RemoveHeader,Message.Strings[i])<>0 then
      begin
        delete(s,pos(RemoveHeader,s),length(Message.Strings[i])+2);
      end;
    end;
    message.text:=s;
  end;
end;

function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
begin
  RemoveAnyHeader(Message,IsEmail);
  result:=true;
end;

begin
end.

Script by anchedo (Andreas Loch)