DataU1.pas
上传用户:dh8233980
上传日期:2014-10-16
资源大小:1015k
文件大小:104k
源码类别:

Email服务器

开发平台:

Delphi

  1. unit DataU1;
  2. (******************************************************************************)
  3. (*                                                                            *)
  4. (* SMTP Server Data Objects                                                   *)
  5. (* Part of Hermes SMTP/POP3 Server.                                           *)
  6. (* Copyright(C) 2000 by Alexander J. Fanti, All Rights Reserver Worldwide.    *)
  7. (*                                                                            *)
  8. (* Contains: TServerInformation, TPop3UserInformation, TPop3MailInformation   *)
  9. (*           TMailListInformation, TMessageRouteInformation                   *)
  10. (*                                                                            *)
  11. (* Created January 13, 2000 by Alexander J. Fanti.  See License.txt           *)
  12. (*                                                                            *)
  13. (* Depends on: UtilU1                                                         *)
  14. (* Also Uses: WSocket (Francois Piette Internet Component Suite)              *)
  15. (*                                                                            *)
  16. (* Used by: Virtually everything                                              *)
  17. (*                                                                            *)
  18. (* Description:                                                               *)
  19. (* TServerInformation - This is the Server Application's main Object.  It     *)
  20. (*                      contains ALL data relevant to the server (ports to    *)
  21. (*                      use, bind addresses, etc.).  It can load and save     *)
  22. (*                      this data, and manage it.  It also exposes services   *)
  23. (*                      that other objects use to interpret this data.        *)
  24. (* TPop3UserInformation - This object is used to manipulate a single user.    *)
  25. (*                        It contains all relevant user data, and can load    *)
  26. (*                        and save this data.  It also allows manitulation of *)
  27. (*                        the data, and exposes some services.                *)
  28. (* TPop3MailInformation - This object is used to collect and interpret        *)
  29. (*                        information about a single user's mailbox.  It can  *)
  30. (*                        get a list of messages and deal with them (delete,  *)
  31. (*                        etc).                                               *)
  32. (* TMailListInformation - This object is used to manipulate a single mail     *)
  33. (*                        list.  It contains all list data, cal load and save *)
  34. (*                        the data and exposes services to interpret and      *)
  35. (*                        manage the data.                                    *)
  36. (* TMessageRouteInformation - This object is used to manipulate a mail route. *)
  37. (*                            The route is in the format specified by the SMTP*)
  38. (*                            RFC (<@domain,@[IPAddress]:"mailbox"@domain>)   *)
  39. (*                            It can parse a string into a route, and can     *)
  40. (*                            assemble a string from a route.                 *)
  41. (*                                                                            *)
  42. (* Revisions: 1/29/2000  AJF  Commented                                       *)
  43. (*            2/12/2000  AJF  Added Start Minimized                           *)
  44. (*            2/12/2000  AJF  Added Data and Interface to manage Smtp Server  *)
  45. (*                            access (for anti-spam)                          *)
  46. (*            2/13/3000  AJF  Added Startup options                           *)
  47. (*            3/11/2000  AJF  Added DNS Timeout and Process Queue on Startup  *)
  48. (*                                                                            *)
  49. (******************************************************************************)
  50. interface
  51. uses Windows, Messages, Classes, SysUtils, FileCtrl, INIFiles;
  52. const
  53.   AppVersion = '1.4.0.0';            // Application Version (for About Dialog)
  54.   AppWebSite = 'http://www.alixoft.com';  // App Web site.
  55.   AuthorEMail = 'mailto:alex@alixoft.com'; // my email address
  56.   ServerRoot  = 'C:Program FilesAlixoftHermes';
  57.   ALIASSEPERATOR = '<==>';  // constant used to seperate AliasID and AliasUser
  58.                             // in Alias String internal storage
  59.   INVALIDNAMECHARACTERS = '( ) < > @ , ; :  " [ ]'; // These cannpt appear
  60.                                                      // in a mailbox name
  61.   // Status Levels, used in StatusUpdate events to indicate the "level"
  62.   // of the status message
  63.   STAT_CRITICALERROR = 0;
  64.   STAT_SERVERERROR = 1;
  65.   STAT_SERVEREVENT = 2;
  66.   STAT_CONNECTIONERROR = 3;
  67.   STAT_CONNECTIONEVENT = 4;
  68.   STAT_COMMANDERROR = 5;
  69.   STAT_COMMANDEVENT = 6;
  70.   STAT_PROCESSINGERROR = 7;
  71.   STAT_PROCESSINGEVENT = 8;
  72. type
  73.   TBannerLevel = (bannerlevel_NameVersionService, bannerlevel_NameService, bannerlevel_Service);
  74.   TServerInformation = class(TObject)
  75.   private
  76.     FAppPath : String;
  77.     FStartMinimized : Boolean; // True if user wants to start minimized...
  78.     FStartProcessQueueOnStartup : Boolean;  // if True, then process queue on start
  79.     // True if we're to start whatever on startup
  80.     FAutoStart_SmtpServer : Boolean;
  81.     FAutoStart_SmtpAgent  : Boolean;
  82.     FAutoStart_Pop3Server : Boolean;
  83.     FServerName : String;    // Used by Pop3Server for APOP ID,
  84.                              // SmtpServer for it's domain and domain of users
  85.                              // SmtpAgent as it's Domain when connect to others
  86.     FMailBoxPath : String;   // Pop3 Users folders are here ( terminated)
  87.                              // (username = foldername)
  88.                              // one file = username.ini is user settings.
  89.                              // all other files are mail to be delivered
  90.     FMailListPath : String;  // Mail list folder.  Each mail list is storred
  91.                              // here by listname.ini  ( terminated)
  92.     FMailQueuePath : String; // Incoming mail (from SMTP) that must be delivered
  93.                              // non-local goes here for Agent files are
  94.                              // ###.ini (message info) and ###.txt (message)
  95.                              // ( terminated)
  96.     FDNSServerAddress : String; // IP address of DNS server to use for
  97.                                 // MX domain resolution
  98.     FDNSServerTimeout : Integer; // Number of seconds SMTP Agent waits
  99.                                  // for DNS to answer
  100.     FFQLogFilename : String; // Fully qualified Log file to log everything to...
  101.     FLogLevel : Integer;     // The number (and below) of events to report
  102.     FLogSpyMessageContent : Boolean;
  103.     FBanner_Level : TBannerLevel;
  104.     FPop3_BindAddress : String;                // Bind address (to listen to)
  105.     FPop3_Port : Integer;                      // Port to listen to
  106.     FPop3_CreateUserOnDemand : Boolean;        // if TRUE we make user folder
  107.                                                // and info on login
  108.     FPop3_CreateUserPasswordOnDemand: Boolean; // if true we change password to
  109.                                                // whatever's supplied (if blank)
  110.     FPop3_InactivityTimeout : Integer;         // Inactivity Timeout in Minutes
  111.     FSmtp_BindAddress : String;    // Bind address (to listen to)
  112.     FSmtp_Port : Integer;          // Port to listen to
  113.     FSmtp_Domains : TStringList;   // List of Domains the SMTP server will
  114.                                    // accept mail for
  115.     FSmtp_Retries : Integer;       // How many retries do we attempt on a
  116.                                    // message we're trying to forward?
  117.     // These are for access control for the Smtp Server (who can send, etc.)
  118.     FSmtp_Access_BanDomains : Boolean;    // reject mail from "banned" domains
  119.     FSmtp_Access_BanMailboxes : Boolean;  // reject mail from "banned" mailboxes
  120.     FSmtp_Access_BanAddresses : Boolean;  // reject mail from "banned" Addresses
  121.     FSmtp_Access_OnlyForUnderXUsers : Boolean;   // Accept mail only if To count
  122.     FSmtp_Access_OnlyForUsersCount : Longint;    // is lower than this!
  123.     FSmtp_Access_Restricted : Boolean;
  124.     FSmtp_Access_AcceptedDomains : TStringList;  // List of Domains the server
  125.                                                  // will accept mail from
  126.     FSmtp_Access_BannedMailBoxes : TStringList;  // List of mailboxes the server
  127.                                                  // will reject mail from
  128.     FSmtp_Access_BannedDomains : TStringList;    // List of Domains the SMTP
  129.                                                  // server will accept mail from
  130.     FSmtp_Access_BannedAddresses : TStringList;  // List of Addresses the SMTP
  131.                                                  // server will accept mail from
  132.                                                  // (connection)
  133.     FSmtp_InactivityTimeout : Integer;         // Inactivity Timeout in Minutes
  134.     FAgent_PollingInterval : Longint; // Time in seconds between polls...
  135.     FAgent_ServiceQueueImmediately : Boolean; // if true, post message to make
  136.                                               // queue fire immediately
  137.     FAgent_ForwardToMasterSMTP : Boolean;  // True if we don't try to deliver,
  138.                                            // but just forward
  139.     FAgent_MasterServerIPAddress : String; // The dotted IP address of the SMTP
  140.                                            // server to forward to.
  141.     FAgent_InactivityTimeout : Integer;         // Inactivity Timeout in Minutes
  142.     FUser_Aliases : TStringList;   // Alias<==>UserID format stringlist
  143.     procedure SetMailBoxPath(Path : String);
  144.     procedure SetMailListPath(Path : String);
  145.     procedure SetMailQueuePath(Path : String);
  146.     procedure SetAgentPollingInterval(Interval : Longint);
  147.   public
  148.     constructor Create;
  149.     destructor Destroy; Override;
  150.     procedure Initialize;
  151.     function Exists : Boolean;
  152.     function LoadFromFile : Boolean;
  153.     function SaveToFile   : Boolean;
  154.     property Pop3_BindAddress : String
  155.              read FPop3_BindAddress write FPop3_BindAddress;
  156.     property Pop3_Port : Integer
  157.              read FPop3_Port write FPop3_Port;
  158.     property Pop3_CreateUserOnDemand : Boolean
  159.              read FPop3_CreateUserOnDemand write FPop3_CreateUserOnDemand;
  160.     property Pop3_CreateUserPasswordOnDemand : Boolean
  161.              read FPop3_CreateUserPasswordOnDemand
  162.              write FPop3_CreateUserPasswordOnDemand;
  163.     property Pop3_InactivityTimeout : Integer
  164.              read FPop3_InactivityTimeout write FPop3_InactivityTimeout;
  165.     property Smtp_BindAddress : String
  166.              read FSmtp_BindAddress write FSmtp_BindAddress;
  167.     property Smtp_Port : Integer
  168.              read FSmtp_Port write FSmtp_Port;
  169.     property Smtp_Domains : TStringList read FSmtp_Domains;
  170.     procedure SetSmtp_Domains(Strings : TStrings);
  171.     property Smtp_Access_AcceptedDomains : TStringList
  172.              read FSmtp_Access_AcceptedDomains;
  173.     procedure SetSmtp_Access_AcceptedDomains(Strings : TStrings);
  174.     property Smtp_Access_BannedMailboxes : TStringList
  175.              read FSmtp_Access_BannedMailboxes;
  176.     procedure SetSmtp_Access_BannedMailBoxes(Strings : TStrings);
  177.     property Smtp_Access_BannedDomains : TStringList
  178.              read FSmtp_Access_BannedDomains;
  179.     procedure SetSmtp_Access_BannedDomains(Strings : TStrings);
  180.     property Smtp_Access_BannedAddresses : TStringList
  181.              read FSmtp_Access_BannedAddresses;
  182.     procedure SetSmtp_Access_BannedAddresses(Strings : TStrings);
  183.     property Smtp_Retries : Integer read FSmtp_Retries write FSmtp_Retries;
  184.     property Smtp_InactivityTimeout : Integer
  185.              read FSmtp_InactivityTimeout write FSmtp_InactivityTimeout;
  186.     property Agent_PollingInterval : Longint
  187.              read FAgent_PollingInterval write SetAgentPollingInterval;
  188.     property Agent_ServiceQueueImmediately : Boolean
  189.              read FAgent_ServiceQueueImmediately
  190.              write FAgent_ServiceQueueImmediately;
  191.     property Agent_ForwardToMasterSMTP : Boolean
  192.              read FAgent_ForwardToMasterSMTP write FAgent_ForwardToMasterSMTP;
  193.     property Agent_MasterServerIPAddress : String
  194.              read FAgent_MasterServerIPAddress write FAgent_MasterServerIPAddress;
  195.     property Agent_InactivityTimeout : Integer
  196.              read FAgent_InactivityTimeout write FAgent_InactivityTimeout;
  197.     function Domain_IsThisOneOfMine(Domain : String) : Boolean;
  198.     function MailBox_IsThisOneOfMine(Mailbox : String) : Boolean;
  199.     function Smtp_Access_IsThisDomainAccepted(Domain : String) : Boolean;
  200.     function Smtp_Access_IsThisMailboxBanned(Mailbox : String) : Boolean;
  201.     function Smtp_Access_IsThisDomainBanned(Domain : String) : Boolean;
  202.     function Smtp_Access_IsThisAddressBanned(Address : String) : Boolean;
  203.     property Smtp_Access_BanDomains : Boolean
  204.              read FSmtp_Access_BanDomains write FSmtp_Access_BanDomains;
  205.     property Smtp_Access_BanAddresses : Boolean
  206.              read FSmtp_Access_BanAddresses write FSmtp_Access_BanAddresses;
  207.     property Smtp_Access_BanMailboxes : Boolean
  208.              read FSmtp_Access_BanMailboxes write FSmtp_Access_BanMailboxes;
  209.     property Smtp_Access_OnlyForUnderXUsers : Boolean
  210.              read FSmtp_Access_OnlyForUnderXUsers
  211.              write FSmtp_Access_OnlyForUnderXUsers;
  212.     property Smtp_Access_OnlyForUsersCount : Longint
  213.              read FSmtp_Access_OnlyForUsersCount
  214.              write FSmtp_Access_OnlyForUsersCount;
  215.     property Smtp_Access_Restricted : Boolean
  216.              read FSmtp_Access_Restricted write FSmtp_Access_Restricted;
  217.     property StartMinimized : Boolean
  218.              read FStartMinimized write FStartMinimized;
  219.     property ProcessQueueOnStartup : Boolean
  220.              read FStartProcessQueueOnStartup write FStartProcessQueueOnStartup;
  221.     property AutoStart_SmtpServer : Boolean
  222.              read FAutoStart_SmtpServer write FAutoStart_SmtpServer;
  223.     property AutoStart_SmtpAgent : Boolean
  224.              read FAutoStart_SmtpAgent write FAutoStart_SmtpAgent;
  225.     property AutoStart_Pop3Server : Boolean
  226.              read FAutoStart_Pop3Server write FAutoStart_Pop3Server;
  227.     property AppPath       : String read FAppPath;
  228.     property ServerName    : String read FServerName    write FServerName;
  229.     property MailBoxPath   : String read FMailBoxPath   write SetMailBoxPath;
  230.     property MailListPath  : String read FMailListPath  write SetMailListPath;
  231.     property MailQueuePath : String read FMailQueuePath write SetMailQueuePath;
  232.     property DNSServerAddress : String
  233.              read FDNSServerAddress write FDNSServerAddress;
  234.     property DNSServerTimeout : Integer read FDNSServerTimeout write FDNSServerTimeout;
  235.     property LogFile : String read FFQLogFilename write FFQLogFilename;
  236.     property LogLevel : Integer read FLogLevel write FLogLevel;
  237.     property LogSpyMessageContent : Boolean read FLogSpyMessageContent write FLogSpyMessageContent;
  238.     property Banner_Level : TBannerLevel read FBanner_Level write FBanner_Level;
  239.     function TimeStamp : String;
  240.     procedure User_GetList(Strings : TStrings);
  241.     function User_Exists(UserName : String) : Boolean;
  242.     function User_Create(UserName : String) : Boolean;
  243.     function User_Delete(UserName : String) : Boolean;
  244.     function User_Rename(OldUserName, NewUserName : String) : Boolean;
  245.     procedure List_GetList(Strings : TStrings);
  246.     function List_Exists(ListName : String) : Boolean;
  247.     function List_Create(ListName : String) : Boolean;
  248.     function List_Delete(ListName : String) : Boolean;
  249.     function List_Rename(OldListName, NewListName : String) : Boolean;
  250.     procedure Alias_Parse(AliasString : String; var AliasID : String;
  251.                           var AliasUser : String);
  252.     procedure Alias_SetList(Strings : TStrings);
  253.     procedure Alias_GetList(Strings : TStrings);
  254.     function Alias_Exists(AliasIDorAlias : String) : Boolean;
  255.     function Alias_Create(AliasID, AliasUser : String) : Boolean;
  256.     procedure Alias_Delete(AliasIDorAlias : String);
  257.     function Alias_Rename(OldAliasIDorAlias, NewAliasID : String) : Boolean;
  258.     function Alias_Find(AliasIDorAlias : String) : String;
  259.     function Alias_Edit(AliasIDorAlias, NewAliasUser : String) : Boolean;
  260.   end;
  261.   TPop3UserInformation = class(TObject)
  262.   private
  263.     FUserName : String;
  264.     FPassword : String;
  265.     FForwardToAddress : String;
  266.     FRealName : String;
  267.     FUB_DoNotReportUserExists_SMTP : Boolean;  // SMTP VRFY will fail
  268.     FLimit_MessageToBytes, FLimit_MailboxToBytes, FLimit_MailboxToMessages : Longint;
  269.   public
  270.     constructor Create;
  271.     destructor Destroy; Override;
  272.     property UserName : String read FUserName;
  273.     property Password : String read FPassword write FPassword;
  274.     property ForwardToAddress : String
  275.              read FForwardToAddress write FForwardToAddress;
  276.     property RealName : String read FRealName write FRealName;
  277.     property UB_DoNotReportUserExists_SMTP : Boolean
  278.              read FUB_DoNotReportUserExists_SMTP
  279.              write FUB_DoNotReportUserExists_SMTP;
  280.     property Limit_MessageToBytes : Longint read FLimit_MessageToBytes write FLimit_MessageToBytes;
  281.     property Limit_MailboxToBytes : Longint read FLimit_MailboxToBytes write FLimit_MailboxToBytes;
  282.     property Limit_MailboxToMessages : Longint read FLimit_MailboxToMessages write FLimit_MailboxToMessages;
  283.     procedure Initialize;
  284.     function LoadFromFile(UserName : String) : Boolean;
  285.     function SaveToFile(UserName : String) : Boolean; Overload;
  286.     function SaveToFile : Boolean; Overload;
  287.     function SaveMail(SL : TStringList) : Boolean;
  288.   end;
  289.   TMailListMemberInfoRec = record
  290.     Active : Boolean;    // True if this member is active
  291.     Manager : Boolean;   // True if this member is a manager
  292.     EMail : String[255]; // address of member (may be local)
  293.     // Unsupported as of now... /
  294.     Hidden : Boolean;    // True if member address must not be listed
  295.                          // by listserver.  Does not affect SMTP EXPN command
  296.   end;
  297.   PMailListMemberInfoRec = ^TMailListMemberInfoRec;
  298.   TMailListPendingMemberInfoRec = record
  299.     ExpirationDate : TDateTime; // after this date... they can't join
  300.                                 // (and must be purged)
  301.     EMail : String[255];        // address of member (may be local)
  302.     MagicNumber : Integer;      // the number they must match to really get
  303.                                 // subscribed
  304.   end;
  305.   PMailListPendingMemberInfoRec = ^TMailListPendingMemberInfoRec;
  306.   TMailListInformation = class(TObject)
  307.   private
  308.     FFileDateTime : TDateTime;  // File Date so we can tell if it was edited
  309.                                 // since we opened it (for save purposes)
  310.     FMembers : TList;           // List of members (PMailListMemberInfoRec)
  311.     FPendingMembers : TList;    // List of pending members
  312.                                 // (PMailListPendingMemberInfoRec)
  313.     FPassword : String;         // Required in some list commands (in mail body)
  314.     FErrorsMailedTo : String;   // e-mail address to send errors to...
  315.     FFile_Welcome   : String;   // File send on subscription to list
  316.     FFile_Signature : String;   // File appended to every mail sent from list
  317.     FFile_Farewell  : String;   // File sent on removal from list
  318.     FSL_Welcome   : TStringList; // Strings sent on subscription to list
  319.     FSL_Signature : TStringList; // Strings appended to each mail sent from list
  320.     FSL_Farewell  : TStringList; // Strings sent on removal from list
  321.     // List Behaviors
  322.     FLB_AllowPublicSubscription     : Boolean;  // Anyone can subscribe to list
  323.                                                 // (as opposed to managers
  324.                                                 //  subscribing people)
  325.     FLB_ForceRepliesToList          : Boolean;  // Change mail (Reply To to
  326.                                                 // list address
  327.     FLB_DoNotReportListMembers_SMTP : Boolean;  // EXPN Command will fail
  328.     FLB_DoNotReportListExists       : Boolean;  // List Lists command will omit
  329.     FLB_DoNotReportListMembers      : Boolean;  // List Member command will fail
  330.     FLB_MemberSubmissionOnly        : Boolean;  // Only members or managers may
  331.                                                 // mail to list
  332.     FArchiveFile : String;          // Keep copy of all list messages
  333.                                     // (append to this file)
  334.     function GetMembers(Index : Longint) : PMailListMemberInfoRec;
  335.     function GetMemberCount : Longint;
  336.     function GetPendingMembers(Index : Longint) : PMailListPendingMemberInfoRec;
  337.     function GetPendingMemberCount : Longint;
  338.   public
  339.     constructor Create;
  340.     destructor Destroy; Override;
  341.     procedure Initialize;
  342.     function LoadFromFile(ListName : String) : Boolean;
  343.     function SaveToFile(ListName : String; Force : Boolean) : Boolean;
  344.     property Members[Index : Longint] : PMailListMemberInfoRec read GetMembers;
  345.     property MemberCount : Longint read GetMemberCount;
  346.     function MemberAdd(Active, Manager : Boolean; EMail : String) :
  347.              PMailListMemberInfoRec;
  348.     procedure MemberDelete(Index : Longint);
  349.     procedure MembersClear;
  350.     property PendingMembers[Index : Longint] : PMailListPendingMemberInfoRec
  351.              read GetPendingMembers;
  352.     property PendingMemberCount : Longint read GetPendingMemberCount;
  353.     function PendingMemberAdd(ExpirationDate : TDateTime;
  354.                               MagicNumber : Integer; EMail : String)
  355.                               : PMailListPendingMemberInfoRec;
  356.     procedure PendingMemberDelete(Index : Longint); Overload;
  357.     procedure PendingMemberDelete(TargetListMember
  358.                                   : PMailListPendingMemberInfoRec); Overload;
  359.     procedure PendingMembersClear;
  360.     function PendingMember_FindByMagicNumber(MagicNumber : Integer)
  361.              : PMailListPendingMemberInfoRec;
  362.     function PendingMember_NewMagicNumber : Integer;
  363.     property Password : String read FPassword write FPassword;
  364.     property ErrorsMailedTo : String read FErrorsMailedTo write FErrorsMailedTo;
  365.     property File_Welcome   : String read FFile_Welcome write FFile_Welcome;
  366.     property File_Signature : String read FFile_Signature write FFile_Signature;
  367.     property File_Farewell  : String read FFile_Farewell write FFile_Farewell;
  368.     property SL_Welcome : TStringList read FSL_Welcome;
  369.     procedure SetSL_Welcome(Strings : TStrings);
  370.     property SL_Signature : TStringList read FSL_Signature;
  371.     procedure SetSL_Signature(Strings : TStrings);
  372.     property SL_Farewell : TStringList read FSL_Farewell;
  373.     procedure SetSL_Farewell(Strings : TStrings);
  374.     property LB_AllowPublicSubscription     : Boolean
  375.              read FLB_AllowPublicSubscription write FLB_AllowPublicSubscription;
  376.     property LB_ForceRepliesToList          : Boolean
  377.              read FLB_ForceRepliesToList write FLB_ForceRepliesToList;
  378.     property LB_DoNotReportListMembers_SMTP : Boolean
  379.              read FLB_DoNotReportListMembers_SMTP
  380.              write FLB_DoNotReportListMembers_SMTP;
  381.     property LB_DoNotReportListExists       : Boolean
  382.              read FLB_DoNotReportListExists write FLB_DoNotReportListExists;
  383.     property LB_DoNotReportListMembers      : Boolean
  384.              read FLB_DoNotReportListMembers write FLB_DoNotReportListMembers;
  385.     property LB_MemberSubmissionOnly        : Boolean
  386.              read FLB_MemberSubmissionOnly write FLB_MemberSubmissionOnly;
  387.     property ArchiveFile : String read FArchiveFile write FArchiveFile;
  388.   end;
  389.   TPop3MailEntry = record
  390.     Number : Longint;
  391.     Filename : String[255];
  392.     FileSize : Longint;
  393.     MarkForDelete : Boolean;
  394.   end;
  395.   PPop3MailEntry = ^TPop3MailEntry;
  396.   TPop3MailInformation = class(TObject)
  397.   private
  398.     FFolderPath : String;  // Set on "ReadFolder" and used on
  399.                            // "DeleteMarkedMessages" and "SaveToFile"
  400.     FMail : TList;
  401.     function GetCount : Longint;
  402.     function GetDeletedCount : Longint;
  403.     function GetByteCount : Longint;
  404.     function GetMailEntry(Index: Integer) : PPop3MailEntry;
  405.     procedure DropAllMail;
  406.   public
  407.     constructor Create;
  408.     destructor Destroy; Override;
  409.     procedure ReadFolder(UserName : String);
  410.     function DeleteMarkedMessages : Longint;
  411.     property Mail[Index: Integer] : PPop3MailEntry read GetMailEntry;
  412.     function Find(ID : Integer) : PPop3MailEntry;
  413.     property Count : Longint read GetCount;
  414.     property CountDeleted : Longint read GetDeletedCount;
  415.     property ByteCount : Longint read GetByteCount;
  416.   end;
  417.   TMessageRouteInformation_Kind = (mrte_Unknown, mrte_To, mrte_From);
  418.   TMessageRouteInformation = class(TObject)
  419.   private
  420.     FKind : TMessageRouteInformation_Kind;
  421.     FHosts : TStringList;  // The list of hosts the mail has been through
  422.              // 0 = left most in list, Count -1 = right most in list
  423.              // if mode = To then Host 0 = you or next domain to send to
  424.              // if mode = From then Host 0 = last domain sent from
  425.              // (who sent you mail)
  426.     FMailbox : String;  // The mailbox the mail is from or to
  427.     FDomain  : String;  // The domain the mail is from or to
  428.   public
  429.     constructor Create(Kind : TMessageRouteInformation_Kind);
  430.     destructor Destroy; Override;
  431.     procedure Initialize;
  432.     function ParseRoute(Route : String) : Integer;
  433.     function BuildRoute : String;
  434.     property Kind : TMessageRouteInformation_Kind read FKind;
  435.     property Domain : String read FDomain;
  436.     property Mailbox : String read FMailbox;
  437.     property Hosts : TStringList read FHosts;
  438.   end;
  439.   PMessageRouteInformation = ^TMessageRouteInformation;
  440.   TWHComponent_WindowsMessage = procedure(Sender : TObject; Msg: TMessage)
  441.                                 of object;
  442.   TWHComponent = class(TComponent)
  443.   private
  444.     FHandle : HWnd;
  445.     FWindowsMessage : TWHComponent_WindowsMessage;
  446.     function GetWindowHandle(Obj : TObject) : HWnd;
  447.     procedure WinProc(var Msg: TMessage);
  448.   public
  449.     constructor Create(AOwner: TComponent); override;
  450.     destructor Destroy; override;
  451.     property Handle : HWND read FHandle;
  452.     property OnWindowsMessage : TWHComponent_WindowsMessage
  453.              read FWindowsMessage write FWindowsMessage;
  454.   end;
  455.   function IsNameValid(Name : String) : Boolean;
  456.   function IsNameValidIncludingAt(Name : String) : Boolean;
  457.   function StatusLevelDescription(Level : Integer) : String;
  458. var
  459.   INI : TServerInformation;
  460. implementation
  461. uses UtilU1, WSocket {For Local IP list only};
  462. constructor TServerInformation.Create;
  463. begin
  464.   inherited Create;
  465.   Randomize;
  466.   FAppPath := IncludeTrailingBackslash(ServerRoot);
  467.   FSmtp_Domains := TStringList.Create;
  468.   FSmtp_Access_AcceptedDomains := TStringList.Create;
  469.   FSmtp_Access_BannedMailBoxes := TStringList.Create;
  470.   FSmtp_Access_BannedDomains := TStringList.Create;
  471.   FSmtp_Access_BannedAddresses := TStringList.Create;
  472.   FUser_Aliases := TStringList.Create;
  473.   Initialize;
  474. end;
  475. destructor TServerInformation.Destroy;
  476. begin
  477.   FSmtp_Domains.Free;
  478.   FSmtp_Access_AcceptedDomains.Free;
  479.   FSmtp_Access_BannedMailBoxes.Free;
  480.   FSmtp_Access_BannedDomains.Free;
  481.   FSmtp_Access_BannedAddresses.Free;
  482.   FUser_Aliases.Free;
  483.   inherited Destroy;
  484. end;
  485. procedure TServerInformation.Initialize;
  486. begin
  487.   FStartMinimized := False;
  488.   FStartProcessQueueOnStartup := False;
  489.   FAutoStart_SmtpServer := True;
  490.   FAutoStart_SmtpAgent  := True;
  491.   FAutoStart_Pop3Server := True;
  492.   FServerName := 'Unknown';
  493.   if LocalIPList.Count > 0 then FServerName := LocalIPList[0];
  494.   MailBoxPath := FAppPath + 'UserMail';
  495.   MailListPath := FAppPath + 'UserMail';
  496.   MailQueuePath := FAppPath + 'MQueue';
  497.   FDNSServerAddress := '';
  498.   FDNSServerTimeout := 15;
  499.   FPop3_BindAddress := '0.0.0.0';
  500.   FPop3_Port := 110;
  501.   FPop3_CreateUserOnDemand := False;
  502.   FPop3_CreateUserPasswordOnDemand := False;
  503.   FPop3_InactivityTimeout := 15;
  504.   FSmtp_BindAddress := '0.0.0.0';
  505.   FSmtp_Port := 25;
  506.   FSmtp_Domains.Clear;
  507.   FSmtp_Access_AcceptedDomains.Clear;
  508.   FSmtp_Access_BannedMailBoxes.Clear;
  509.   FSmtp_Access_BannedDomains.Clear;
  510.   FSmtp_Access_BannedAddresses.Clear;
  511.   FSmtp_Access_BanDomains := False;
  512.   FSmtp_Access_BanAddresses := False;
  513.   FSmtp_Access_BanMailboxes := False;
  514. //  FSmtp_Access_AcceptAcceptableDomains := False;
  515. //  FSmtp_Access_AcceptFromLocalDomains := False;
  516. //  FSmtp_Access_AcceptFromLocalUsers := False;
  517. //  FSmtp_Access_OnlyForLocalUsers := False;
  518.   FSmtp_Access_OnlyForUnderXUsers := False;
  519.   FSmtp_Access_OnlyForUsersCount := 10000;
  520.   FSmtp_Access_Restricted := False;
  521.   FSmtp_Retries := 5;
  522.   FSmtp_InactivityTimeout := 15;
  523. //  FSmtp_Forward := True;
  524.   FUser_Aliases.Clear;
  525.   FAgent_ForwardToMasterSMTP := False;
  526.   FAgent_MasterServerIPAddress := '';
  527.   FAgent_InactivityTimeout := 15;
  528. end;
  529. procedure TServerInformation.SetMailBoxPath(Path : String);
  530. begin
  531.   // Be certain path is  terminated
  532.   if Copy(Path, Length(Path), 1) <> '' then Path := Path + '';
  533.   // Be certain path exists
  534.   if not DirectoryExists(Path) then try
  535.     ForceDirectories(Path);
  536.   except
  537.     on E: Exception do begin {what to do if path can't be created ?} end;
  538.   end;
  539.   FMailBoxPath := Path;
  540. end;
  541. procedure TServerInformation.SetMailListPath(Path : String);
  542. begin
  543.   // Be certain path is  terminated
  544.   if Copy(Path, Length(Path), 1) <> '' then Path := Path + '';
  545.   // Be certain path exists
  546.   if not DirectoryExists(Path) then try
  547.     ForceDirectories(Path);
  548.   except
  549.     on E: Exception do begin {what to do if path can't be created ?} end;
  550.   end;
  551.   FMailListPath := Path;
  552. end;
  553. procedure TServerInformation.SetMailQueuePath(Path : String);
  554. begin
  555.   // Be certain path is  terminated
  556.   if Copy(Path, Length(Path), 1) <> '' then Path := Path + '';
  557.   // Be certain path exists
  558.   if not DirectoryExists(Path) then try
  559.     ForceDirectories(Path);
  560.   except
  561.     on E: Exception do begin {what to do if path can't be created ?} end;
  562.   end;
  563.   FMailQueuePath := Path;
  564. end;
  565. procedure TServerInformation.SetAgentPollingInterval(Interval : Longint);
  566. begin
  567.   // Interval is specified in seconds
  568.   if Interval > 36000 then Interval := 36000; // never more than 10 hours
  569.   if Interval < 10 then Interval := 10;       // never less than 10 seconds
  570.   FAgent_PollingInterval := Interval;
  571. end;
  572. procedure TServerInformation.SetSmtp_Domains(Strings : TStrings);
  573. var
  574.   x : Longint;
  575. begin
  576.   if Assigned(Strings) then begin
  577.     FSmtp_Domains.Clear;
  578.     for x := 0 to Strings.Count -1 do FSmtp_Domains.Add(Strings[x]);
  579.   end;
  580. end;
  581. procedure TServerInformation.SetSmtp_Access_AcceptedDomains(Strings : TStrings);
  582. var
  583.   x : Longint;
  584. begin
  585.   if Assigned(Strings) then begin
  586.     FSmtp_Access_AcceptedDomains.Clear;
  587.     for x := 0 to Strings.Count -1 do
  588.       FSmtp_Access_AcceptedDomains.Add(Strings[x]);
  589.   end;
  590. end;
  591. procedure TServerInformation.SetSmtp_Access_BannedMailBoxes(Strings : TStrings);
  592. var
  593.   x : Longint;
  594. begin
  595.   if Assigned(Strings) then begin
  596.     FSmtp_Access_BannedMailBoxes.Clear;
  597.     for x := 0 to Strings.Count -1 do
  598.       FSmtp_Access_BannedMailBoxes.Add(Strings[x]);
  599.   end;
  600. end;
  601. procedure TServerInformation.SetSmtp_Access_BannedDomains(Strings : TStrings);
  602. var
  603.   x : Longint;
  604. begin
  605.   if Assigned(Strings) then begin
  606.     FSmtp_Access_BannedDomains.Clear;
  607.     for x := 0 to Strings.Count -1 do
  608.       FSmtp_Access_BannedDomains.Add(Strings[x]);
  609.   end;
  610. end;
  611. procedure TServerInformation.SetSmtp_Access_BannedAddresses(Strings : TStrings);
  612. var
  613.   x : Longint;
  614. begin
  615.   if Assigned(Strings) then begin
  616.     FSmtp_Access_BannedAddresses.Clear;
  617.     for x := 0 to Strings.Count -1 do
  618.       FSmtp_Access_BannedAddresses.Add(Strings[x]);
  619.   end;
  620. end;
  621. function TServerInformation.Domain_IsThisOneOfMine(Domain : String) : Boolean;
  622. var
  623.   x : Longint;
  624.   Found : Boolean;
  625. begin
  626.   Found := False;
  627.   Domain := LowerCase(Trim(Domain));  // we must be case insensitive !
  628.   if Domain <> '' then begin
  629.     if Domain = INI.ServerName then Found := True
  630.     else begin
  631.       x := 0;
  632.       while (not Found) and (x < FSmtp_Domains.Count) do
  633.         if LowerCase(FSmtp_Domains[x]) = Domain then Found := True
  634.           else Inc(x);
  635.     end;
  636.   end;
  637.   Result := Found;
  638. end;
  639. function TServerInformation.MailBox_IsThisOneOfMine(Mailbox : String) : Boolean;
  640. begin
  641.   Result := FileExists(INI.MailBoxPath + MailBox + '' + MailBox + '.ini');
  642. end;
  643. function TServerInformation.Smtp_Access_IsThisDomainAccepted(Domain : String)
  644.                                                             : Boolean;
  645. var
  646.   x : Longint;
  647.   Found : Boolean;
  648.   OurDomain : String;
  649. begin
  650.   Found := False;
  651.   Domain := LowerCase(Trim(Domain));  // we must be case insensitive !
  652.   if Domain <> '' then begin
  653.     x := 0;
  654.     while (not Found) and (x < FSmtp_Access_AcceptedDomains.Count) do begin
  655.       OurDomain := LowerCase(FSmtp_Access_AcceptedDomains[x]);
  656.       if Pos('*', OurDomain) > 0 then begin
  657.         OurDomain := Copy(OurDomain, 1, Pos('*', OurDomain) -1);
  658.         if OurDomain = Copy(Domain, 1, Length(OurDomain)) then Found := True
  659.           else Inc(x);
  660.       end else begin
  661.         if OurDomain = Domain then Found := True
  662.           else Inc(x);
  663.       end;
  664.     end;
  665.   end;
  666.   Result := Found;
  667. end;
  668. function TServerInformation.Smtp_Access_IsThisMailboxBanned(Mailbox : String)
  669.                                                            : Boolean;
  670. var
  671.   x : Longint;
  672.   Found : Boolean;
  673.   OurMailbox : String;
  674. begin
  675.   Found := False;
  676.   Mailbox := LowerCase(Trim(Mailbox));  // we must be case insensitive !
  677.   if Mailbox <> '' then begin
  678.     x := 0;
  679.     while (not Found) and (x < FSmtp_Access_BannedMailBoxes.Count) do begin
  680.       OurMailbox := LowerCase(FSmtp_Access_BannedMailBoxes[x]);
  681.       if Pos('*', OurMailbox) > 0 then begin
  682.         OurMailbox := Copy(OurMailbox, 1, Pos('*', OurMailbox) -1);
  683.         if OurMailbox = Copy(Mailbox, 1, Length(OurMailbox)) then Found := True
  684.           else Inc(x);
  685.       end else begin
  686.         if OurMailbox = Mailbox then Found := True
  687.           else Inc(x);
  688.       end;
  689.     end;
  690.   end;
  691.   Result := Found;
  692. end;
  693. function TServerInformation.Smtp_Access_IsThisDomainBanned(Domain : String)
  694.                                                           : Boolean;
  695. var
  696.   x : Longint;
  697.   Found : Boolean;
  698.   OurDomain : String;
  699. begin
  700.   Found := False;
  701.   Domain := LowerCase(Trim(Domain));  // we must be case insensitive !
  702.   if Domain <> '' then begin
  703.     x := 0;
  704.     while (not Found) and (x < FSmtp_Access_BannedDomains.Count) do begin
  705.       OurDomain := LowerCase(FSmtp_Access_BannedDomains[x]);
  706.       if Pos('*', OurDomain) > 0 then begin
  707.         OurDomain := Copy(OurDomain, 1, Pos('*', OurDomain) -1);
  708.         if OurDomain = Copy(Domain, 1, Length(OurDomain)) then Found := True
  709.           else Inc(x);
  710.       end else begin
  711.         if OurDomain = Domain then Found := True
  712.           else Inc(x);
  713.       end;
  714.     end;
  715.   end;
  716.   Result := Found;
  717. end;
  718. function TServerInformation.Smtp_Access_IsThisAddressBanned(Address : String)
  719.                                                             : Boolean;
  720. var
  721.   x : Longint;
  722.   Found : Boolean;
  723.   OurAddress : String;
  724. begin
  725.   Found := False;
  726.   Address := LowerCase(Trim(Address));  // we must be case insensitive !
  727.   if Address <> '' then begin
  728.     x := 0;
  729.     while (not Found) and (x < FSmtp_Access_BannedAddresses.Count) do begin
  730.       OurAddress := LowerCase(FSmtp_Access_BannedAddresses[x]);
  731.       if Pos('*', OurAddress) > 0 then begin
  732.         OurAddress := Copy(OurAddress, 1, Pos('*', OurAddress) -1);
  733.         if OurAddress = Copy(Address, 1, Length(OurAddress)) then Found := True
  734.           else Inc(x);
  735.       end else begin
  736.         if OurAddress = Address then Found := True
  737.           else Inc(x);
  738.       end;
  739.     end;
  740.   end;
  741.   Result := Found;
  742. end;
  743. function ReturnShortDay(Day : Word) : String;
  744. begin
  745.   case Day of
  746.     1: Result := 'Sun';
  747.     2: Result := 'Mon';
  748.     3: Result := 'Tue';
  749.     4: Result := 'Wed';
  750.     5: Result := 'Thu';
  751.     6: Result := 'Fri';
  752.     7: Result := 'Sat';
  753.   end;
  754. end;
  755. function ReturnShortMonth(Month : Word) : String;
  756. begin
  757.   case Month of
  758.     1: Result := 'Jan';
  759.     2: Result := 'Feb';
  760.     3: Result := 'Mar';
  761.     4: Result := 'Apr';
  762.     5: Result := 'May';
  763.     6: Result := 'Jun';
  764.     7: Result := 'Jul';
  765.     8: Result := 'Aug';
  766.     9: Result := 'Sep';
  767.     10: Result := 'Oct';
  768.     11: Result := 'Nov';
  769.     12: Result := 'Dec';
  770.   end;
  771. end;
  772. function TServerInformation.TimeStamp : String;
  773. var
  774.   Year, Month, Day: Word;
  775. begin
  776.   // Format = DD Mon YR HH:MM:SS Zone
  777. //  Result := FormatDateTime('dd mmm yy hh:mm:ss', Now) + ' ' + GetTimeZoneString;
  778.   // Format = Day, DD Mon YEAR HH:MM:SS Zone
  779. //  Result := FormatDateTime('ddd, d mmm yyyy hh:mm:ss', Now) + ' ' + GetTimeZoneString;
  780.   DecodeDate(Date, Year, Month, Day);
  781.   Result := ReturnShortDay(DayOfWeek(Date)) + ', ' + IntToStr(Day) + ' ' + ReturnShortMonth(Month) + ' ' + IntToStr(Year) + ' ' + FormatDateTime('hh:mm:ss', Time) + ' ' + GetTimeZoneString;
  782. end;
  783. function TServerInformation.Exists : Boolean;
  784. begin
  785.   Result := FileExists(AppPath + 'Hermes.ini');
  786. end;
  787. function TServerInformation.LoadFromFile : Boolean;
  788. var
  789.   Filename : String;
  790.   FINI : TINIFile;
  791.   x : Longint;
  792.   tempStr : String;
  793. begin
  794.   Filename := AppPath + 'Hermes.ini';
  795.   try
  796.     FINI := TINIFile.Create(Filename);
  797.     try
  798.       FStartMinimized := FINI.ReadBool('General', 'Start Minimized', False);
  799.       FStartProcessQueueOnStartup := FINI.ReadBool('General', 'Process Queue on Start', False);
  800.       FAutoStart_SmtpServer := FINI.ReadBool('General',
  801.                                              'AutoStart Smtp Server', True);
  802.       FAutoStart_SmtpAgent  := FINI.ReadBool('General',
  803.                                              'AutoStart Smtp Agent', True);
  804.       FAutoStart_Pop3Server := FINI.ReadBool('General',
  805.                                              'AutoStart Pop3 Server', True);
  806.       FServerName := FINI.ReadString('General', 'Server Name', '');
  807.       if (FServerName = '') and (LocalIPList.Count > 0) then
  808.         FServerName := LocalIPList[0];
  809.       FMailboxPath := FINI.ReadString('Directories', 'Mail Box Path',
  810.                                       AppPath + 'UserMail');
  811.       if FMailboxPath = '' then FMailboxPath := AppPath + 'UserMail';
  812.       if not DirectoryExists(FMailboxPath) then
  813.         ForceDirectories(FMailboxPath);
  814.       FMailQueuePath := FINI.ReadString('Directories', 'Queue Path',
  815.                                         AppPath + 'MQueue');
  816.       if FMailQueuePath = '' then FMailQueuePath := AppPath + 'MQueue';
  817.       if not DirectoryExists(FMailQueuePath) then
  818.         ForceDirectories(FMailQueuePath);
  819.       FMailListPath := FINI.ReadString('Directories', 'Mailing List Path',
  820.                                        AppPath + 'UserMail');
  821.       if FMailListPath = '' then FMailListPath := AppPath + 'UserMail';
  822.       if not DirectoryExists(FMailListPath) then
  823.         ForceDirectories(FMailListPath);
  824.       FDNSServerAddress := FINI.ReadString('General', 'DNS Server Address', '');
  825.       if FDNSServerAddress <> '' then
  826.         if not IsDomainDottedIP(FDNSServerAddress) then FDNSServerAddress := '';
  827.       FDNSServerTimeout := FINI.ReadInteger('General', 'DNS Server Timeout', 15);
  828.       FFQLogFilename := FINI.ReadString('General', 'Log File', '');
  829.       FLogLevel := FINI.ReadInteger('General', 'Log Level', 0);
  830.       FLogSpyMessageContent := FINI.ReadBool('General', 'Log Message Spy', False);
  831.       FBanner_Level := bannerlevel_NameVersionService;
  832.       tempStr := UpperCase(Trim(FINI.ReadString('General', 'Banner Level', '')));
  833.       if tempStr = 'Service' then FBanner_Level := bannerlevel_Service;
  834.       if tempStr = 'Name and Service' then FBanner_Level := bannerlevel_NameService;
  835.       // Pop3 Server Settings
  836.       FPop3_BindAddress := FINI.ReadString('Pop 3 Server', 'Bind Address',
  837.                                            '0.0.0.0');
  838.       if FPop3_BindAddress = '' then FPop3_BindAddress := '0.0.0.0';
  839.       FPop3_Port := FINI.ReadInteger('Pop 3 Server', 'Listen Port', 110);
  840.       if FPop3_Port < 1 then FPop3_Port := 110;
  841.       FPop3_CreateUserOnDemand := FINI.ReadBool('Pop 3 Server',
  842.                                                 'Create User On Demand', False);
  843.       FPop3_CreateUserPasswordOnDemand := FINI.ReadBool('Pop 3 Server',
  844.                                           'Create User Password On Demand',
  845.                                           False);
  846.       FPop3_InactivityTimeout := FINI.ReadInteger('Pop 3 Server',
  847.                                       'Inactivity Timeout (in minutes)', 15);
  848.       // Smtp Server Settings
  849.       FSmtp_BindAddress := FINI.ReadString('Smtp Server', 'Bind Address',
  850.                                            '0.0.0.0');
  851.       if FSmtp_BindAddress = '' then FSmtp_BindAddress := '0.0.0.0';
  852.       FSmtp_Port := FINI.ReadInteger('Smtp Server', 'Listen Port', 25);
  853.       if FSmtp_Port < 1 then FSmtp_Port := 25;
  854.       FSmtp_Domains.Clear;
  855.       FINI.ReadSectionValues('Smtp Server Domains', FSmtp_Domains);
  856.       // Clean out "x="
  857.       for x := 0 to FSmtp_Domains.Count -1 do
  858.         if Pos('=', FSmtp_Domains[x]) > 0 then
  859.           FSmtp_Domains[x] := Copy(FSmtp_Domains[x],
  860.                                    Pos('=', FSmtp_Domains[x]) +1,
  861.                                    Length(FSmtp_Domains[x]));
  862.       FSmtp_InactivityTimeout := FINI.ReadInteger('Smtp Server',
  863.                                       'Inactivity Timeout (in minutes)', 15);
  864.       // SMTP Server Access
  865.       FSmtp_Access_AcceptedDomains.Clear;
  866.       FINI.ReadSectionValues('Smtp Server Access - Accepted Domains',
  867.                              FSmtp_Access_AcceptedDomains);
  868.       for x := 0 to FSmtp_Access_AcceptedDomains.Count -1 do
  869.         if Pos('=', FSmtp_Access_AcceptedDomains[x]) > 0 then
  870.           FSmtp_Access_AcceptedDomains[x]
  871.             := Copy(FSmtp_Access_AcceptedDomains[x],
  872.                Pos('=', FSmtp_Access_AcceptedDomains[x]) +1,
  873.                Length(FSmtp_Access_AcceptedDomains[x]));
  874.       FSmtp_Access_BannedMailBoxes.Clear;
  875.       FINI.ReadSectionValues('Smtp Server Access - Banned Mailboxes',
  876.                              FSmtp_Access_BannedMailBoxes);
  877.       for x := 0 to FSmtp_Access_BannedMailBoxes.Count -1 do
  878.         if Pos('=', FSmtp_Access_BannedMailBoxes[x]) > 0 then
  879.           FSmtp_Access_BannedMailBoxes[x]
  880.             := Copy(FSmtp_Access_BannedMailBoxes[x],
  881.                Pos('=', FSmtp_Access_BannedMailBoxes[x]) +1,
  882.                Length(FSmtp_Access_BannedMailBoxes[x]));
  883.       FSmtp_Access_BannedDomains.Clear;
  884.       FINI.ReadSectionValues('Smtp Server Access - Banned Domains',
  885.                              FSmtp_Access_BannedDomains);
  886.       for x := 0 to FSmtp_Access_BannedDomains.Count -1 do
  887.         if Pos('=', FSmtp_Access_BannedDomains[x]) > 0 then
  888.           FSmtp_Access_BannedDomains[x]
  889.             := Copy(FSmtp_Access_BannedDomains[x],
  890.                Pos('=', FSmtp_Access_BannedDomains[x]) +1,
  891.                Length(FSmtp_Access_BannedDomains[x]));
  892.       FSmtp_Access_BannedAddresses.Clear;
  893.       FINI.ReadSectionValues('Smtp Server Access - Banned Addresses',
  894.                              FSmtp_Access_BannedAddresses);
  895.       for x := 0 to FSmtp_Access_BannedAddresses.Count -1 do
  896.         if Pos('=', FSmtp_Access_BannedAddresses[x]) > 0 then
  897.           FSmtp_Access_BannedAddresses[x]
  898.             := Copy(FSmtp_Access_BannedAddresses[x],
  899.                Pos('=', FSmtp_Access_BannedAddresses[x]) +1,
  900.                Length(FSmtp_Access_BannedAddresses[x]));
  901.       FSmtp_Access_BanDomains := FINI.ReadBool('Smtp Server Access Control',
  902.                                                'Ban Domains', False);
  903.       FSmtp_Access_BanAddresses := FINI.ReadBool('Smtp Server Access Control',
  904.                                                  'Ban Addresses', False);
  905.       FSmtp_Access_BanMailboxes := FINI.ReadBool('Smtp Server Access Control',
  906.                                                  'Ban Mailboxes', False);
  907. //      FSmtp_Access_AcceptAcceptableDomains := FINI.ReadBool(
  908. //                                                  'Smtp Server Access Control',
  909. //                                                  'Accepted Domains', False);
  910. //      FSmtp_Access_AcceptFromLocalDomains := FINI.ReadBool(
  911. //                                             'Smtp Server Access Control',
  912. //                                             'Local Domains Only', False);
  913. //      FSmtp_Access_AcceptFromLocalUsers := FINI.ReadBool(
  914. //                                           'Smtp Server Access Control',
  915. //                                           'Local Mailboxes Only', False);
  916. //      FSmtp_Access_OnlyForLocalUsers := FINI.ReadBool(
  917. //                                        'Smtp Server Access Control',
  918. //                                        'For Local Mailboxes Only', False);
  919.       FSmtp_Access_OnlyForUnderXUsers := FINI.ReadBool(
  920.                                          'Smtp Server Access Control',
  921.                                          'Apply To Maximum', False);
  922.       FSmtp_Access_OnlyForUsersCount := FINI.ReadInteger(
  923.                                          'Smtp Server Access Control',
  924.                                          'To Maximum', 1000);
  925.       FSmtp_Access_Restricted := FINI.ReadBool('Smtp Server Access Control',
  926.                                                'Restrict', False);
  927. //      FSmtp_Forward := FINI.ReadBool('Smtp Server', 'Forward Mail', True);
  928.       FSmtp_Retries := FINI.ReadInteger('Smtp Server', 'Forward Retries', 5);
  929.       // Agent information
  930.       FAgent_PollingInterval := FINI.ReadInteger('Smtp Agent',
  931.                                 'Polling Interval (in seconds)', 300);
  932.       FAgent_ServiceQueueImmediately := FINI.ReadBool('Smtp Agent',
  933.                                         'Fire Queue Immediately', False);
  934.       FAgent_ForwardToMasterSMTP := FINI.ReadBool('Smtp Agent',
  935.                                     'Forward to Master SMTP Server', False);
  936.       FAgent_MasterServerIPAddress := FINI.ReadString('Smtp Agent',
  937.                                       'Master SMTP Server', '');
  938.       FAgent_InactivityTimeout := FINI.ReadInteger('Smtp Agent',
  939.                                        'Inactivity Timeout (in minutes)', 15);
  940.       FUser_Aliases.Clear;
  941.       FINI.ReadSectionValues('User EMail Aliases', FUser_Aliases);
  942.       // Clean out "x="
  943.       for x := 0 to FUser_Aliases.Count -1 do
  944.         if Pos('=', FUser_Aliases[x]) > 0 then
  945.           FUser_Aliases[x] := Copy(FUser_Aliases[x],
  946.                                    Pos('=', FUser_Aliases[x]) +1,
  947.                                    Length(FUser_Aliases[x]));
  948.     finally
  949.       FINI.Free;
  950.     end;
  951.     Result := True;
  952.   except
  953.     on E: Exception do Result := False;
  954.   end;
  955. end;
  956. function TServerInformation.SaveToFile : Boolean;
  957. var
  958.   Filename : String;
  959.   FINI : TINIFile;
  960.   x : Longint;
  961. begin
  962.   Filename := AppPath + 'Hermes.ini';
  963.   try
  964.     FINI := TINIFile.Create(Filename);
  965.     try
  966.       FINI.WriteBool('General', 'Start Minimized', FStartMinimized);
  967.       FINI.WriteBool('General', 'Process Queue on Start', FStartProcessQueueOnStartup);
  968.       FINI.WriteBool('General', 'AutoStart Smtp Server', FAutoStart_SmtpServer);
  969.       FINI.WriteBool('General', 'AutoStart Smtp Agent', FAutoStart_SmtpAgent);
  970.       FINI.WriteBool('General', 'AutoStart Pop3 Server', FAutoStart_Pop3Server);
  971.       FINI.WriteString('General', 'Server Name', FServerName);
  972.       FINI.WriteString('Directories', 'Mail Box Path', FMailboxPath);
  973.       FINI.WriteString('Directories', 'Queue Path', FMailQueuePath);
  974.       FINI.WriteString('Directories', 'Mailing List Path', FMailListPath);
  975.       FINI.WriteString('General', 'DNS Server Address', FDNSServerAddress);
  976.       FINI.WriteInteger('General', 'DNS Server Timeout', FDNSServerTimeout);
  977.       FINI.WriteString('General', 'Log File', FFQLogFilename);
  978.       FINI.WriteInteger('General', 'Log Level', FLogLevel);
  979.       FINI.WriteBool('General', 'Log Message Spy', FLogSpyMessageContent);
  980.       case FBanner_Level of
  981.         bannerlevel_NameVersionService : FINI.WriteString('General', 'Banner Level', 'Name, Version and Service');
  982.         bannerlevel_NameService        : FINI.WriteString('General', 'Banner Level', 'Name and Service');
  983.         bannerlevel_Service            : FINI.WriteString('General', 'Banner Level', 'Service');
  984.       end;
  985.       // Pop3 Server Settings
  986.       FINI.WriteString('Pop 3 Server', 'Bind Address', FPop3_BindAddress);
  987.       FINI.WriteInteger('Pop 3 Server', 'Listen Port', FPop3_Port);
  988.       FINI.WriteBool('Pop 3 Server', 'Create User On Demand',
  989.                      FPop3_CreateUserOnDemand);
  990.       FINI.WriteBool('Pop 3 Server', 'Create User Password On Demand',
  991.                      FPop3_CreateUserPasswordOnDemand);
  992.       FINI.WriteInteger('Pop 3 Server', 'Inactivity Timeout (in minutes)',
  993.                        FPop3_InactivityTimeout);
  994.       // Smtp Server Settings
  995.       FINI.WriteString('Smtp Server', 'Bind Address', FSmtp_BindAddress);
  996.       FINI.WriteInteger('Smtp Server', 'Listen Port', FSmtp_Port);
  997.       FINI.EraseSection('Smtp Server Domains');
  998.       for x := 0 to FSmtp_Domains.Count -1 do
  999.         FINI.WriteString('Smtp Server Domains', IntToStr(x), FSmtp_Domains[x]);
  1000.       FINI.WriteInteger('Smtp Server', 'Inactivity Timeout (in minutes)',
  1001.                        FSmtp_InactivityTimeout);
  1002.       // SMTP Server Access
  1003.       FINI.EraseSection('Smtp Server Access - Accepted Domains');
  1004.       for x := 0 to FSmtp_Access_AcceptedDomains.Count -1 do
  1005.         FINI.WriteString('Smtp Server Access - Accepted Domains', IntToStr(x),
  1006.                          FSmtp_Access_AcceptedDomains[x]);
  1007.       FINI.EraseSection('Smtp Server Access - Banned Mailboxes');
  1008.       for x := 0 to FSmtp_Access_BannedMailBoxes.Count -1 do
  1009.         FINI.WriteString('Smtp Server Access - Banned Mailboxes', IntToStr(x),
  1010.                          FSmtp_Access_BannedMailBoxes[x]);
  1011.       FINI.EraseSection('Smtp Server Access - Banned Domains');
  1012.       for x := 0 to FSmtp_Access_BannedDomains.Count -1 do
  1013.         FINI.WriteString('Smtp Server Access - Banned Domains', IntToStr(x),
  1014.                          FSmtp_Access_BannedDomains[x]);
  1015.       FINI.EraseSection('Smtp Server Access - Banned Addresses');
  1016.       for x := 0 to FSmtp_Access_BannedAddresses.Count -1 do
  1017.         FINI.WriteString('Smtp Server Access - Banned Addresses', IntToStr(x),
  1018.                          FSmtp_Access_BannedAddresses[x]);
  1019.       FINI.WriteBool('Smtp Server Access Control', 'Ban Domains',
  1020.                      FSmtp_Access_BanDomains);
  1021.       FINI.WriteBool('Smtp Server Access Control', 'Ban Addresses',
  1022.                      FSmtp_Access_BanAddresses);
  1023.       FINI.WriteBool('Smtp Server Access Control', 'Ban Mailboxes',
  1024.                      FSmtp_Access_BanMailboxes);
  1025. //      FINI.WriteBool('Smtp Server Access Control', 'Accepted Domains',
  1026. //                     FSmtp_Access_AcceptAcceptableDomains);
  1027. //      FINI.WriteBool('Smtp Server Access Control', 'Local Domains Only',
  1028. //                     FSmtp_Access_AcceptFromLocalDomains);
  1029. //      FINI.WriteBool('Smtp Server Access Control', 'Local Mailboxes Only',
  1030. //                     FSmtp_Access_AcceptFromLocalUsers);
  1031. //      FINI.WriteBool('Smtp Server Access Control', 'For Local Mailboxes Only',
  1032. //                     FSmtp_Access_OnlyForLocalUsers);
  1033.       FINI.WriteBool('Smtp Server Access Control', 'Apply To Maximum',
  1034.                      FSmtp_Access_OnlyForUnderXUsers);
  1035.       FINI.WriteInteger('Smtp Server Access Control', 'To Maximum',
  1036.                         FSmtp_Access_OnlyForUsersCount);
  1037.       FINI.WriteBool('Smtp Server Access Control', 'Restrict',
  1038.                      FSmtp_Access_Restricted);
  1039. //      FINI.WriteBool('Smtp Server', 'Forward Mail', FSmtp_Forward);
  1040.       FINI.WriteInteger('Smtp Server', 'Forward Retries', FSmtp_Retries);
  1041.       // Agent information
  1042.       FINI.WriteInteger('Smtp Agent', 'Polling Interval (in seconds)',
  1043.                         FAgent_PollingInterval);
  1044.       FINI.WriteBool('Smtp Agent', 'Fire Queue Immediately',
  1045.                      FAgent_ServiceQueueImmediately);
  1046.       FINI.WriteBool('Smtp Agent', 'Forward to Master SMTP Server',
  1047.                      FAgent_ForwardToMasterSMTP);
  1048.       FINI.WriteString('Smtp Agent', 'Master SMTP Server',
  1049.                        FAgent_MasterServerIPAddress);
  1050.       FINI.WriteInteger('Smtp Agent', 'Inactivity Timeout (in minutes)',
  1051.                        FAgent_InactivityTimeout);
  1052.       for x := 0 to FUser_Aliases.Count -1 do
  1053.         FINI.WriteString('User EMail Aliases', IntToStr(x), FUser_Aliases[x]);
  1054.     finally
  1055.       FINI.Free;
  1056.     end;
  1057.     Result := True;
  1058.   except
  1059.     on E: Exception do Result := False;
  1060.   end;
  1061. end;
  1062. procedure TServerInformation.User_GetList(Strings : TStrings);
  1063. var
  1064.   SearchRec: TSearchRec;
  1065.   SearchResult : Longint;
  1066. begin
  1067.   if Assigned(Strings) then begin
  1068.     Strings.Clear;
  1069.     if DirectoryExists(FMailboxPath) then begin
  1070.       SearchResult := FindFirst(FMailboxPath + '*.*', faDirectory, SearchRec);
  1071.       while SearchResult = 0 do begin
  1072.         if (SearchRec.Name <> '.')  and
  1073.            (SearchRec.Name <> '..') and
  1074.            (SearchRec.Name <> '')   and
  1075.            (UpperCase(ExtractFileExt(SearchRec.Name)) <> '.INI') {User INI file}
  1076.           then begin
  1077.           Strings.Add(LowerCase(SearchRec.Name));
  1078.         end;
  1079.         SearchResult := FindNext(SearchRec);
  1080.       end;
  1081.       FindClose(SearchRec);
  1082.     end;
  1083.   end;
  1084. end;
  1085. function TServerInformation.User_Exists(UserName : String) : Boolean;
  1086. begin
  1087.   Result := DirectoryExists(FMailboxPath + UserName + '');
  1088. end;
  1089. function TServerInformation.User_Create(UserName : String) : Boolean;
  1090. var
  1091.   UserInfo : TPop3UserInformation;
  1092. begin
  1093.   Result := True;
  1094.   if not User_Exists(UserName) then begin
  1095.     UserInfo := TPop3UserInformation.Create;
  1096.     Result := UserInfo.SaveToFile(UserName);
  1097.     UserInfo.Free;
  1098.   end;
  1099. end;
  1100. function TServerInformation.User_Delete(UserName : String) : Boolean;
  1101. var
  1102.   x : Integer;
  1103.   SearchRec: TSearchRec;
  1104.   SearchResult : Longint;
  1105.   SL : TStringList;
  1106.   OK : Boolean;
  1107.   AliasID, AliasUser : String;
  1108. begin
  1109.   OK := True;
  1110.   // Delete all files in the User Folder and delete the folder
  1111.   // Get list of files to delete
  1112.   SL := TStringList.Create;
  1113.   SearchResult := FindFirst(FMailboxPath + UserName + '*.*',
  1114.                             faAnyFile, SearchRec);
  1115.   while SearchResult = 0 do begin
  1116.     if (SearchRec.Name <> '.')  and
  1117.        (SearchRec.Name <> '..') and
  1118.        (SearchRec.Name <> '')   then SL.Add(SearchRec.Name);
  1119.     SearchResult := FindNext(SearchRec);
  1120.   end;
  1121.   FindClose(SearchRec);
  1122.   // Delete individual files
  1123.   for x := 0 to SL.Count -1 do begin
  1124.     if FileExists(FMailboxPath + UserName + '' + SL[x]) then
  1125.       if not FileOperation(FMailboxPath + UserName + '' + SL[x], '', 'DELETE')
  1126.         then OK := False;
  1127.   end;
  1128.   // Delete folder
  1129.   if DirectoryExists(FMailboxPath + UserName) then
  1130.     if not FileOperation(FMailboxPath + UserName, '', 'DELETE') then
  1131.       OK := False;
  1132.   // Delete any aliases
  1133.   for x := FUser_Aliases.Count -1 downto 0 do begin
  1134.     Alias_Parse(FUser_Aliases[x], AliasID, AliasUser);
  1135.     if LowerCase(UserName) = LowerCase(AliasUser) then FUser_Aliases.Delete(x);
  1136.     // or  FUser_Aliases[x] := AliasID + ALIASSEPERATOR; // remove User ID?
  1137.   end;
  1138.   Result := OK;
  1139. end;
  1140. function TServerInformation.User_Rename(OldUserName,
  1141.                                         NewUserName : String) : Boolean;
  1142. var
  1143.   OK : Boolean;
  1144.   x : Longint;
  1145.   AliasID, AliasUser : String;
  1146. begin
  1147.   OK := True;
  1148.   if LowerCase(NewUserName) <> LowerCase(OldUserName) then begin
  1149.     if User_Exists(NewUserName) then OK := False;
  1150.     if List_Exists(NewUserName) then OK := False;
  1151.     if Alias_Exists(NewUserName) then OK := False;
  1152.     if not IsNameValid(NewUserName) then OK := False;
  1153.     if OK then begin
  1154.       // Rename folder
  1155.       if not FileOperation(FMailboxPath + OldUserName,
  1156.                            FMailboxPath + NewUserName, 'RENAME') then
  1157.         OK := False;
  1158.       // Rename User INI file
  1159.       if not FileOperation(FMailboxPath + NewUserName + '' +
  1160.                            OldUserName + '.ini',
  1161.                            FMailboxPath + NewUserName + '' +
  1162.                            NewUserName + '.ini', 'RENAME') then OK := False;
  1163.       // Rename any aliases !
  1164.       for x := 0 to FUser_Aliases.Count -1 do begin
  1165.         Alias_Parse(FUser_Aliases[x], AliasID, AliasUser);
  1166.         if LowerCase(OldUserName) = LowerCase(AliasUser) then
  1167.           FUser_Aliases[x] := AliasID + ALIASSEPERATOR + NewUserName;
  1168.       end;
  1169.     end;
  1170.   end;
  1171.   Result := OK;
  1172. end;
  1173. procedure TServerInformation.List_GetList(Strings : TStrings);
  1174. var
  1175.   SearchRec: TSearchRec;
  1176.   SearchResult : Longint;
  1177. begin
  1178.   if Assigned(Strings) then begin
  1179.     Strings.Clear;
  1180.     if DirectoryExists(FMailListPath) then begin
  1181.       SearchResult := FindFirst(FMailListPath + '*.*', faAnyFile, SearchRec);
  1182.       while SearchResult = 0 do begin
  1183.         if (SearchRec.Name <> '.')  and
  1184.            (SearchRec.Name <> '..') and
  1185.            (SearchRec.Name <> '')   and
  1186.            (UpperCase(ExtractFileExt(SearchRec.Name)) = '.INI') {List INI file}
  1187.           then begin
  1188.           Strings.Add(LowerCase(Copy(SearchRec.Name, 1,
  1189.                                      Length(SearchRec.Name) -4)));
  1190.         end;
  1191.         SearchResult := FindNext(SearchRec);
  1192.       end;
  1193.       FindClose(SearchRec);
  1194.     end;
  1195.   end;
  1196. end;
  1197. function TServerInformation.List_Exists(ListName : String) : Boolean;
  1198. begin
  1199.   Result := FileExists(FMailListPath + ListName + '.ini');
  1200. end;
  1201. function TServerInformation.List_Create(ListName : String) : Boolean;
  1202. var
  1203.   ListInfo : TMailListInformation;
  1204. begin
  1205.   Result := True;
  1206.   if not List_Exists(ListName) then begin
  1207.     ListInfo := TMailListInformation.Create;
  1208.     Result := ListInfo.SaveToFile(ListName, True);
  1209.     ListInfo.Free;
  1210.   end;
  1211. end;
  1212. function TServerInformation.List_Delete(ListName : String) : Boolean;
  1213. begin
  1214.   Result := False;
  1215.   if List_Exists(ListName) then begin
  1216.     // Delete List INI file
  1217.     if FileExists(FMailListPath + ListName + '.ini') then
  1218.       Result := FileOperation(FMailListPath + ListName + '.ini', '', 'DELETE');
  1219.   end;
  1220. end;
  1221. function TServerInformation.List_Rename(OldListName,
  1222.                                         NewListName : String) : Boolean;
  1223. var
  1224.   OK : Boolean;
  1225. begin
  1226.   OK := True;
  1227.   if LowerCase(NewListName) <> LowerCase(OldListName) then begin
  1228.     if User_Exists(NewListName) then OK := False;
  1229.     if List_Exists(NewListName) then OK := False;
  1230.     if Alias_Exists(NewListName) then OK := False;
  1231.     if not IsNameValid(NewListName) then OK := False;
  1232.     if OK then begin
  1233.       // Rename List INI file
  1234.       OK := FileOperation(FMailListPath + OldListName + '.ini',
  1235.                           FMailListPath + NewListName + '.ini', 'RENAME');
  1236.     end;
  1237.   end;
  1238.   Result := OK;
  1239. end;
  1240. procedure TServerInformation.Alias_SetList(Strings : TStrings);
  1241. var
  1242.   x : Longint;
  1243. begin
  1244.   if Assigned(Strings) then begin
  1245.     FUser_Aliases.Clear;
  1246.     for x := 0 to Strings.Count -1 do FUser_Aliases.Add(Strings[x]);
  1247.   end;
  1248. end;
  1249. procedure TServerInformation.Alias_GetList(Strings : TStrings);
  1250. var
  1251.   x : Longint;
  1252. begin
  1253.   if Assigned(Strings) then begin
  1254.     Strings.Clear;
  1255.     for x := 0 to FUser_Aliases.Count -1 do Strings.Add(FUser_Aliases[x]);
  1256.   end;
  1257. end;
  1258. // AliadID = name
  1259. // Alias   = name<==>username
  1260. procedure TServerInformation.Alias_Parse(AliasString : String;
  1261.                                          var AliasID : String;
  1262.                                          var AliasUser : String);
  1263. begin
  1264.   AliasID := AliasString;
  1265.   AliasUser := '';
  1266.   if Pos(ALIASSEPERATOR, AliasString) > 0 then begin
  1267.     AliasID := Copy(AliasString, 1, Pos(ALIASSEPERATOR, AliasString) -1);
  1268.     AliasUser := Copy(AliasString, Pos(ALIASSEPERATOR, AliasString) +
  1269.                       Length(ALIASSEPERATOR), Length(AliasString));
  1270.   end;
  1271. end;
  1272. function TServerInformation.Alias_Exists(AliasIDorAlias : String) : Boolean;
  1273. var
  1274.   x : Longint;
  1275.   AliasID, AliasUser : String;
  1276.   tempAliasID, tempAliasUser : String;
  1277.   Found : Boolean;
  1278. begin
  1279.   Alias_Parse(AliasIDorAlias, AliasID, AliasUser);
  1280.   x := 0;
  1281.   Found := False;
  1282.   while (not Found) and (x < FUser_Aliases.Count) do begin
  1283.     Alias_Parse(FUser_Aliases[x], tempAliasID, tempAliasUser);
  1284.     if LowerCase(AliasID) = LowerCase(tempAliasID) then
  1285.       Found := True else Inc(x);
  1286.   end;
  1287.   Result := Found;
  1288. end;
  1289. function TServerInformation.Alias_Create(AliasID, AliasUser : String) : Boolean;
  1290. begin
  1291.   Result := False;
  1292.   if not Alias_Exists(AliasID) then begin
  1293.     FUser_Aliases.Add(AliasID + ALIASSEPERATOR + AliasUser);
  1294.     Result := True;
  1295.   end;
  1296. end;
  1297. procedure TServerInformation.Alias_Delete(AliasIDorAlias : String);
  1298. var
  1299.   x : Longint;
  1300.   AliasID, AliasUser : String;
  1301.   tempAliasID, tempAliasUser : String;
  1302. begin
  1303.   Alias_Parse(AliasIDorAlias, AliasID, AliasUser);
  1304.   for x := FUser_Aliases.Count -1 downto 0 do begin
  1305.     Alias_Parse(FUser_Aliases[x], tempAliasID, tempAliasUser);
  1306.     if LowerCase(AliasID) = LowerCase(tempAliasID) then FUser_Aliases.Delete(x);
  1307.   end;
  1308. end;
  1309. function TServerInformation.Alias_Rename(OldAliasIDorAlias,
  1310.                                          NewAliasID : String) : Boolean;
  1311. var
  1312.   x : Longint;
  1313.   AliasID, AliasUser : String;
  1314.   tempAliasID, tempAliasUser : String;
  1315.   OK : Boolean;
  1316. begin
  1317.   OK := True;
  1318.   if User_Exists(NewAliasID) then OK := False;
  1319.   if List_Exists(NewAliasID) then OK := False;
  1320.   if Alias_Exists(NewAliasID) then OK := False;
  1321.   if not IsNameValid(NewAliasID) then OK := False;
  1322.   if OK then begin
  1323.     Alias_Parse(OldAliasIDorAlias, AliasID, AliasUser);
  1324.     for x := FUser_Aliases.Count -1 downto 0 do begin
  1325.       Alias_Parse(FUser_Aliases[x], tempAliasID, tempAliasUser);
  1326.       if LowerCase(AliasID) = LowerCase(tempAliasID) then begin
  1327.         FUser_Aliases[x] := NewAliasID + ALIASSEPERATOR + tempAliasUser;
  1328.       end;
  1329.     end;
  1330.   end;
  1331.   Result := OK;
  1332. end;
  1333. function TServerInformation.Alias_Find(AliasIDorAlias : String) : String;
  1334. var
  1335.   x : Longint;
  1336.   AliasID, AliasUser : String;
  1337.   tempAliasID, tempAliasUser : String;
  1338.   Found : Boolean;
  1339. begin
  1340.   Result := '';
  1341.   Alias_Parse(AliasIDorAlias, AliasID, AliasUser);
  1342.   x := 0;
  1343.   Found := False;
  1344.   while (not Found) and (x < FUser_Aliases.Count) do begin
  1345.     Alias_Parse(FUser_Aliases[x], tempAliasID, tempAliasUser);
  1346.     if LowerCase(AliasID) = LowerCase(tempAliasID) then
  1347.       Found := True else Inc(x);
  1348.   end;
  1349.   if Found then Result := FUser_Aliases[x];
  1350. end;
  1351. function TServerInformation.Alias_Edit(AliasIDorAlias,
  1352.                                        NewAliasUser : String) : Boolean;
  1353. var
  1354.   x : Longint;
  1355.   AliasID, AliasUser : String;
  1356.   tempAliasID, tempAliasUser : String;
  1357. begin
  1358.   Result := False;
  1359.   Alias_Parse(AliasIDorAlias, AliasID, AliasUser);
  1360.   if Alias_Exists(AliasID) then begin
  1361.     for x := FUser_Aliases.Count -1 downto 0 do begin
  1362.       Alias_Parse(FUser_Aliases[x], tempAliasID, tempAliasUser);
  1363.       if LowerCase(AliasID) = LowerCase(tempAliasID) then begin
  1364.         FUser_Aliases[x] := AliasID + ALIASSEPERATOR + NewAliasUser;
  1365.         Result := True;
  1366.       end;
  1367.     end;
  1368.   end;
  1369. end;
  1370. (******************************************************************************)
  1371. (*                                                                            *)
  1372. (*  START POP3 User Information Object                                        *)
  1373. (*                                                                            *)
  1374. (******************************************************************************)
  1375. constructor TPop3UserInformation.Create;
  1376. begin
  1377.   inherited Create;
  1378.   Initialize;
  1379. end;
  1380. destructor TPop3UserInformation.Destroy;
  1381. begin
  1382.   inherited Destroy;
  1383. end;
  1384. procedure TPop3UserInformation.Initialize;
  1385. begin
  1386.   FUserName := '';
  1387.   FPassword := '';
  1388.   FRealName := '';
  1389.   FUB_DoNotReportUserExists_SMTP := False;
  1390. end;
  1391. function TPop3UserInformation.LoadFromFile(UserName : String) : Boolean;
  1392. var
  1393.   FINI : TINIFile;
  1394.   Filename : String;
  1395. begin
  1396.   Result := False;
  1397.   FUserName := UserName;
  1398.   Filename := INI.MailBoxPath + FUserName + '' + FUserName + '.ini';
  1399.   if DirectoryExists(INI.MailBoxPath + FUserName + '') and
  1400.      FileExists(Filename) then try
  1401.     FINI := TINIFile.Create(Filename);
  1402.     try
  1403.       FPassword := FINI.ReadString('User Information', 'Password', '');
  1404.       FForwardToAddress := FINI.ReadString('User Information',
  1405.                                            'Forward To Address', '');
  1406.       FRealName := FINI.ReadString('User Information', 'Real Name', '');
  1407.       FUB_DoNotReportUserExists_SMTP := FINI.ReadBool('User Information',
  1408.                                         'Do not report User Exists (SMTP)',
  1409.                                         False);
  1410.       FLimit_MessageToBytes  := FINI.ReadInteger('User Information',
  1411.                                                 'Limit Message To Bytes', 0);
  1412.       FLimit_MailboxToBytes  := FINI.ReadInteger('User Information',
  1413.                                                 'Limit Mailbox To Bytes', 0);
  1414.       FLimit_MailboxToMessages  := FINI.ReadInteger('User Information',
  1415.                                                 'Limit Mailbox To Messages', 0);
  1416.       Result := True;
  1417.     finally
  1418.       FINI.Free;
  1419.     end;
  1420.   except
  1421.     on E: Exception do Result := False;
  1422.   end;
  1423. end;
  1424. function TPop3UserInformation.SaveToFile(UserName : String) : Boolean;
  1425. var
  1426.   FINI : TINIFile;
  1427.   Filename : String;
  1428. begin
  1429.   FUserName := UserName;
  1430.   ForceDirectories(INI.MailBoxPath + FUserName + '');
  1431.   Filename := INI.MailBoxPath + FUserName + '' + FUserName + '.ini';
  1432.   try
  1433.     FINI := TINIFile.Create(Filename);
  1434.     try
  1435.       FINI.WriteString('User Information', 'Password', FPassword);
  1436.       FINI.WriteString('User Information', 'Forward To Address',
  1437.                        FForwardToAddress);
  1438.       FINI.WriteString('User Information', 'Real Name', FRealName);
  1439.       FINI.WriteBool('User Information', 'Do not report User Exists (SMTP)',
  1440.                      FUB_DoNotReportUserExists_SMTP);
  1441.       FINI.WriteInteger('User Information', 'Limit Message To Bytes',
  1442.                         FLimit_MessageToBytes);
  1443.       FINI.WriteInteger('User Information', 'Limit Mailbox To Bytes',
  1444.                         FLimit_MailboxToBytes);
  1445.       FINI.WriteInteger('User Information', 'Limit Mailbox To Messages',
  1446.                         FLimit_MailboxToMessages);
  1447.     finally
  1448.       FINI.Free;
  1449.     end;
  1450.     Result := True;
  1451.   except
  1452.     on E: Exception do Result := False;
  1453.   end;
  1454. end;
  1455. function TPop3UserInformation.SaveToFile : Boolean;
  1456. var
  1457.   FINI : TINIFile;
  1458.   Filename : String;
  1459. begin
  1460.   ForceDirectories(INI.MailBoxPath + FUserName + '');
  1461.   Filename := INI.MailBoxPath + FUserName + '' + UserName + '.ini';
  1462.   try
  1463.     FINI := TINIFile.Create(Filename);
  1464.     try
  1465.       FINI.WriteString('User Information', 'Password', FPassword);
  1466.       FINI.WriteString('User Information', 'Forward To Address',
  1467.                        FForwardToAddress);
  1468.       FINI.WriteString('User Information', 'Real Name', FRealName);
  1469.       FINI.WriteBool('User Information', 'Do not report User Exists (SMTP)',
  1470.                      FUB_DoNotReportUserExists_SMTP);
  1471.     finally
  1472.       FINI.Free;
  1473.     end;
  1474.     Result := True;
  1475.   except
  1476.     on E: Exception do Result := False;
  1477.   end;
  1478. end;
  1479. function TPop3UserInformation.SaveMail(SL : TStringList) : Boolean;
  1480. var
  1481.   Filename : String;
  1482. begin
  1483.   Result := False;
  1484.   if Assigned(SL) then begin
  1485.     if not DirectoryExists(INI.MailBoxPath + FUserName + '') then
  1486.       ForceDirectories(INI.MailBoxPath + FUserName + '');
  1487.     Filename := GetUniqueFilename(INI.MailBoxPath + FUserName + '');
  1488.     if Filename <> '' then
  1489.       SL.SaveToFile(INI.MailBoxPath + FUserName + '' + Filename + '.txt');
  1490.   end;
  1491. end;
  1492. (******************************************************************************)
  1493. (*                                                                            *)
  1494. (*  STOP  POP3 User Information Object                                        *)
  1495. (*                                                                            *)
  1496. (******************************************************************************)
  1497. (******************************************************************************)
  1498. (*                                                                            *)
  1499. (*  START Mail List Information Object                                        *)
  1500. (*                                                                            *)
  1501. (******************************************************************************)
  1502. constructor TMailListInformation.Create;
  1503. begin
  1504.   inherited Create;
  1505.   FFileDateTime := 0;
  1506.   FMembers := TList.Create;
  1507.   FPendingMembers := TList.Create;
  1508.   FSL_Welcome   := TStringList.Create;
  1509.   FSL_Signature := TStringList.Create;
  1510.   FSL_Farewell  := TStringList.Create;
  1511.   Initialize;
  1512. end;
  1513. procedure TMailListInformation.MembersClear;
  1514. var
  1515.   x : Longint;
  1516.   ListMember : PMailListMemberInfoRec;
  1517. begin
  1518.   for x := FMembers.Count -1 downto 0 do begin
  1519.     ListMember := FMembers[x];
  1520.     FreeMem(ListMember, SizeOf(TMailListMemberInfoRec));
  1521.     FMembers.Delete(x);
  1522.   end;
  1523. end;
  1524. procedure TMailListInformation.PendingMembersClear;
  1525. var
  1526.   x : Longint;
  1527.   ListMember : PMailListPendingMemberInfoRec;
  1528. begin
  1529.   for x := FPendingMembers.Count -1 downto 0 do begin
  1530.     ListMember := FPendingMembers[x];
  1531.     FreeMem(ListMember, SizeOf(TMailListPendingMemberInfoRec));
  1532.     FPendingMembers.Delete(x);
  1533.   end;
  1534. end;
  1535. destructor TMailListInformation.Destroy;
  1536. begin
  1537.   PendingMembersClear;
  1538.   FPendingMembers.Free;
  1539.   MembersClear;
  1540.   FMembers.Free;
  1541.   FSL_Welcome.Free;
  1542.   FSL_Signature.Free;
  1543.   FSL_Farewell.Free;
  1544.   inherited Destroy;
  1545. end;
  1546. procedure TMailListInformation.Initialize;
  1547. begin
  1548.   MembersClear;
  1549.   PendingMembersClear;
  1550.   FPassword := '';
  1551.   FErrorsMailedTo := '';
  1552.   FFile_Welcome   := '';
  1553.   FFile_Signature := '';
  1554.   FFile_Farewell  := '';
  1555.   FSL_Welcome.Clear;
  1556.   FSL_Signature.Clear;
  1557.   FSL_Farewell.Clear;
  1558.   FLB_AllowPublicSubscription     := True;
  1559.   FLB_ForceRepliesToList          := True;
  1560.   FLB_DoNotReportListMembers_SMTP := False;
  1561.   FLB_DoNotReportListExists       := False;
  1562.   FLB_DoNotReportListMembers      := False;
  1563.   FLB_MemberSubmissionOnly        := False;
  1564.   FArchiveFile := '';
  1565. end;
  1566. function TMailListInformation.GetMembers(Index : Longint)
  1567.          : PMailListMemberInfoRec;
  1568. begin
  1569.   Result := nil;
  1570.   if (Index > -1) and (Index < FMembers.Count) then Result := FMembers[Index];
  1571. end;
  1572. function TMailListInformation.GetPendingMembers(Index : Longint)
  1573.          : PMailListPendingMemberInfoRec;
  1574. begin
  1575.   Result := nil;
  1576.   if (Index > -1) and (Index < FPendingMembers.Count) then
  1577.     Result := FPendingMembers[Index];
  1578. end;
  1579. function TMailListInformation.MemberAdd(Active,
  1580.                                         Manager : Boolean;
  1581.                                         EMail : String)
  1582.                                         : PMailListMemberInfoRec;
  1583. var
  1584.   ListMember : PMailListMemberInfoRec;
  1585. begin
  1586.   Result := nil;
  1587.   if EMail <> '' then begin
  1588.     GetMem(ListMember, SizeOf(TMailListMemberInfoRec));
  1589.     ListMember.Active := Active;
  1590.     ListMember.Manager := Manager;
  1591.     ListMember.EMail := EMail;
  1592.     FMembers.Add(ListMember);
  1593.     Result := ListMember;
  1594.   end;
  1595. end;
  1596. procedure TMailListInformation.MemberDelete(Index : Longint);
  1597. var
  1598.   ListMember : PMailListMemberInfoRec;
  1599. begin
  1600.   if (Index > -1) and (Index < FMembers.Count) then begin
  1601.     ListMember := FMembers[Index];
  1602.     FreeMem(ListMember, SizeOf(TMailListMemberInfoRec));
  1603.     FMembers.Delete(Index);
  1604.   end;
  1605. end;
  1606. function TMailListInformation.GetMemberCount : Longint;
  1607. begin
  1608.   Result := FMembers.Count;
  1609. end;
  1610. function TMailListInformation.PendingMemberAdd(ExpirationDate : TDateTime;
  1611.                                                MagicNumber : Integer;
  1612.                                                EMail : String)
  1613.                                                : PMailListPendingMemberInfoRec;
  1614. var
  1615.   ListMember : PMailListPendingMemberInfoRec;
  1616. begin
  1617.   Result := nil;
  1618.   if EMail <> '' then begin
  1619.     GetMem(ListMember, SizeOf(TMailListPendingMemberInfoRec));
  1620.     ListMember.ExpirationDate := ExpirationDate;
  1621.     ListMember.EMail := EMail;
  1622.     ListMember.MagicNumber := MagicNumber;
  1623.     FPendingMembers.Add(ListMember);
  1624.     Result := ListMember;
  1625.   end;
  1626. end;
  1627. procedure TMailListInformation.PendingMemberDelete(Index : Longint);
  1628. var
  1629.   ListMember : PMailListPendingMemberInfoRec;
  1630. begin
  1631.   if (Index > -1) and (Index < FPendingMembers.Count) then begin
  1632.     ListMember := FPendingMembers[Index];
  1633.     FreeMem(ListMember, SizeOf(TMailListPendingMemberInfoRec));
  1634.     FPendingMembers.Delete(Index);
  1635.   end;
  1636. end;
  1637. procedure TMailListInformation.PendingMemberDelete(TargetListMember
  1638.                                : PMailListPendingMemberInfoRec);
  1639. var
  1640.   x : Longint;
  1641.   ListMember : PMailListPendingMemberInfoRec;
  1642. begin
  1643.   for x := FPendingMembers.Count -1 downto 0 do begin
  1644.     ListMember := FPendingMembers[x];
  1645.     if ListMember = TargetListMember then PendingMemberDelete(x);
  1646.   end;
  1647. end;
  1648. function TMailListInformation.GetPendingMemberCount : Longint;
  1649. begin
  1650.   Result := FPendingMembers.Count;
  1651. end;
  1652. function TMailListInformation.PendingMember_FindByMagicNumber(MagicNumber
  1653.                               : Integer) : PMailListPendingMemberInfoRec;
  1654. var
  1655.   x : Longint;
  1656.   Found : Boolean;
  1657.   ListMember : PMailListPendingMemberInfoRec;
  1658. begin
  1659.   Result := nil;
  1660.   Found := False;
  1661.   x := 0;
  1662.   while (not Found) and (x < FPendingMembers.Count) do begin
  1663.     ListMember := FPendingMembers[x];
  1664.     if ListMember.MagicNumber = MagicNumber then begin
  1665.       Found := True;
  1666.       Result := ListMember;
  1667.     end else Inc(x);
  1668.   end;
  1669. end;
  1670. function TMailListInformation.PendingMember_NewMagicNumber : Integer;
  1671. var
  1672.   x : Longint;
  1673.   Match : Boolean;
  1674.   ListMember : PMailListPendingMemberInfoRec;
  1675.   MagicNumber : Integer;
  1676. begin
  1677.   MagicNumber := 0;
  1678.   Match := True;
  1679.   while Match do begin
  1680.     MagicNumber := Random(10000);
  1681.     Match := False;
  1682.     for x := FPendingMembers.Count -1 downto 0 do begin
  1683.       ListMember := FPendingMembers[x];
  1684.       if ListMember.MagicNumber = MagicNumber then Match := True;
  1685.     end;
  1686.   end;
  1687.   Result := MagicNumber;
  1688. end;
  1689. procedure TMailListInformation.SetSL_Welcome(Strings : TStrings);
  1690. var
  1691.   x : Longint;
  1692. begin
  1693.   if Assigned(Strings) then begin
  1694.     FSL_Welcome.Clear;
  1695.     for x := 0 to Strings.Count -1 do FSL_Welcome.Add(Strings[x]);
  1696.   end;
  1697. end;
  1698. procedure TMailListInformation.SetSL_Signature(Strings : TStrings);
  1699. var
  1700.   x : Longint;
  1701. begin
  1702.   if Assigned(Strings) then begin
  1703.     FSL_Signature.Clear;
  1704.     for x := 0 to Strings.Count -1 do FSL_Signature.Add(Strings[x]);
  1705.   end;
  1706. end;
  1707. procedure TMailListInformation.SetSL_Farewell(Strings : TStrings);
  1708. var
  1709.   x : Longint;
  1710. begin
  1711.   if Assigned(Strings) then begin
  1712.     FSL_Farewell.Clear;
  1713.     for x := 0 to Strings.Count -1 do FSL_Farewell.Add(Strings[x]);
  1714.   end;
  1715. end;
  1716. function TMailListInformation.LoadFromFile(ListName : String) : Boolean;
  1717. var
  1718.   FINI : TINIFile;
  1719.   Filename : String;
  1720.   x : Longint;
  1721.   SL : TStringList;
  1722.   tempStr, MemberStr : String;
  1723.   ListMember : PMailListMemberInfoRec;
  1724.   Active, Manager : Boolean;
  1725.   PendingListMember : PMailListPendingMemberInfoRec;
  1726.   ExpirationDate : TDateTime;
  1727.   MagicNumber : Integer;
  1728.   Address : String;
  1729. begin
  1730.   Result := False;
  1731.   Filename := INI.MailListPath + ListName + '.ini';
  1732.   Initialize;
  1733.   try
  1734.     FINI := TINIFile.Create(Filename);
  1735.     try
  1736.       SL := TStringList.Create;
  1737.       FINI.ReadSectionValues('Members', SL);
  1738.       // Clean out "x="
  1739.       for x := 0 to SL.Count -1 do begin
  1740.         MemberStr := SL[x];
  1741.         if Pos('=', MemberStr) > 0 then
  1742.           MemberStr := Copy(MemberStr, Pos('=', MemberStr) +1,
  1743.                             Length(MemberStr));
  1744.         if Pos(';', MemberStr) > 0 then begin
  1745.           tempStr := Copy(MemberStr, 1, Pos(';', MemberStr) -1);
  1746.           Active := not (UpperCase(tempStr) = 'INACTIVE');
  1747.           MemberStr := Copy(MemberStr, Pos(';', MemberStr) +1,
  1748.                             Length(MemberStr));
  1749.           if Pos(';', MemberStr) > 0 then begin
  1750.             tempStr := Copy(MemberStr, 1, Pos(';', MemberStr) -1);
  1751.             Manager := not (UpperCase(tempStr) = 'NOMANAGER');
  1752.             Address := Copy(MemberStr, Pos(';', MemberStr) +1,
  1753.                             Length(MemberStr));
  1754.             if Address <> '' then begin
  1755.               GetMem(ListMember, SizeOf(TMailListMemberInfoRec));
  1756.               ListMember.Active := Active;
  1757.               ListMember.Hidden := False;  // not implemented yet
  1758.               ListMember.Manager := Manager;
  1759.               ListMember.EMail := Address;
  1760.               FMembers.Add(ListMember);
  1761.             end;
  1762.           end;
  1763.         end;
  1764.       end;
  1765.       SL.Free;
  1766.       SL := TStringList.Create;
  1767.       FINI.ReadSectionValues('Pending Members', SL);
  1768.       // Clean out "x="
  1769.       for x := 0 to SL.Count -1 do begin
  1770.         MemberStr := SL[x];
  1771.         if Pos('=', MemberStr) > 0 then
  1772.           MemberStr := Copy(MemberStr, Pos('=', MemberStr) +1,
  1773.                             Length(MemberStr));
  1774.         if Pos(';', MemberStr) > 0 then begin
  1775.           tempStr := Copy(MemberStr, 1, Pos(';', MemberStr) -1);
  1776.           try
  1777.             ExpirationDate := StrToFloat(tempStr);
  1778.           except
  1779.             on E: Exception do ExpirationDate := Now;
  1780.           end;
  1781.           MemberStr := Copy(MemberStr, Pos(';', MemberStr) +1,
  1782.                             Length(MemberStr));
  1783.           if Pos(';', MemberStr) > 0 then begin
  1784.             tempStr := Copy(MemberStr, 1, Pos(';', MemberStr) -1);
  1785.             try
  1786.               MagicNumber := StrToInt(tempStr);
  1787.             except
  1788.               on E: Exception do MagicNumber := -1;
  1789.             end;
  1790.             Address := Trim(Copy(MemberStr, Pos(';', MemberStr) +1,
  1791.                             Length(MemberStr)));
  1792.             if Address <> '' then begin
  1793.               GetMem(PendingListMember, SizeOf(TMailListPendingMemberInfoRec));
  1794.               PendingListMember.ExpirationDate := ExpirationDate;
  1795.               PendingListMember.MagicNumber := MagicNumber;
  1796.               PendingListMember.EMail := Address;
  1797.               FPendingMembers.Add(PendingListMember);
  1798.             end;
  1799.           end;
  1800.         end;
  1801.       end;
  1802.       SL.Free;
  1803.       FINI.ReadSectionValues('Welcome Message', FSL_Welcome);
  1804.       for x := 0 to FSL_Welcome.Count -1 do begin      // Clean out "x="
  1805.         if Pos('=', FSL_Welcome[x]) > 0 then
  1806.           FSL_Welcome[x] := Copy(FSL_Welcome[x], Pos('=', FSL_Welcome[x]) +1,
  1807.                                  Length(FSL_Welcome[x]));
  1808.         if FSL_Welcome[x] = '<This line intentionally left blank.>' then
  1809.           FSL_Welcome[x] := '';
  1810.       end;
  1811.       FINI.ReadSectionValues('Signature Message', FSL_Signature);
  1812.       for x := 0 to FSL_Signature.Count -1 do begin      // Clean out "x="
  1813.         if Pos('=', FSL_Signature[x]) > 0 then
  1814.           FSL_Signature[x] := Copy(FSL_Signature[x],
  1815.                                    Pos('=', FSL_Signature[x]) +1,
  1816.                                    Length(FSL_Signature[x]));
  1817.         if FSL_Signature[x] = '<This line intentionally left blank.>' then
  1818.           FSL_Signature[x] := '';
  1819.       end;
  1820.       FINI.ReadSectionValues('Farewell Message', FSL_Farewell);
  1821.       for x := 0 to FSL_Farewell.Count -1 do begin      // Clean out "x="
  1822.         if Pos('=', FSL_Farewell[x]) > 0 then
  1823.           FSL_Farewell[x] := Copy(FSL_Farewell[x],
  1824.                                   Pos('=', FSL_Farewell[x]) +1,
  1825.                                   Length(FSL_Farewell[x]));
  1826.         if FSL_Farewell[x] = '<This line intentionally left blank.>' then
  1827.           FSL_Farewell[x] := '';
  1828.       end;
  1829.       FPassword       := FINI.ReadString('Security', 'Password', '');
  1830.       FErrorsMailedTo := FINI.ReadString('General', 'Mail Errors To', '');
  1831.       FFile_Welcome   := FINI.ReadString('Auto Files', 'Welcome', '');
  1832.       FFile_Signature := FINI.ReadString('Auto Files', 'Signature', '');
  1833.       FFile_Farewell  := FINI.ReadString('Auto Files', 'Farewell', '');
  1834.       FLB_AllowPublicSubscription
  1835.       := FINI.ReadBool('List Behavior', 'Allow Open (Public) Subscription',
  1836.                        True);
  1837.       FLB_ForceRepliesToList
  1838.       := FINI.ReadBool('List Behavior', 'Force Replies to List', True);
  1839.       FLB_DoNotReportListMembers_SMTP
  1840.       := FINI.ReadBool('List Behavior', 'Do not report List Members to SMTP',
  1841.                        False);
  1842.       FLB_DoNotReportListExists
  1843.       := FINI.ReadBool('List Behavior', 'Do not report List Exists', False);
  1844.       FLB_DoNotReportListMembers
  1845.       := FINI.ReadBool('List Behavior', 'Do not report List Members', False);
  1846.       FLB_MemberSubmissionOnly
  1847.       := FINI.ReadBool('List Behavior', 'Member-Only Submission', False);
  1848.       FArchiveFile := FINI.ReadString('Digest', 'Filename', '');
  1849.       Result := True;
  1850.       x := FileAge(Filename);
  1851.       if x <> -1 then FFileDateTime := x;
  1852.     finally
  1853.       FINI.Free;
  1854.     end;
  1855.   except
  1856.     on E: Exception do Result := False;
  1857.   end;
  1858. end;
  1859. function TMailListInformation.SaveToFile(ListName : String;
  1860.                                          Force : Boolean) : Boolean;
  1861. var
  1862.   FINI : TINIFile;
  1863.   Filename : String;
  1864.   x : Longint;
  1865.   tempStr : String;
  1866.   ListMember : PMailListMemberInfoRec;
  1867.   PendingListMember : PMailListPendingMemberInfoRec;
  1868.   OK : Boolean;
  1869. begin
  1870.   Result := False;
  1871.   OK := False;
  1872.   Filename := INI.MailListPath + ListName + '.ini';
  1873.   x := FileAge(Filename);
  1874.   if (x <> -1) and (FFileDateTime = x) then OK := True;
  1875.   if (x <> -1) and (FFileDateTime <> x) and (Force) then OK := True;
  1876.   if (x = -1) then OK := True;
  1877.   if OK then
  1878.   try
  1879.     FINI := TINIFile.Create(Filename);
  1880.     try
  1881.       FINI.EraseSection('Members');
  1882.       for x := 0 to FMembers.Count -1 do begin
  1883.         ListMember := FMembers[x];
  1884.         if ListMember.Active then tempStr := 'ACTIVE;'
  1885.           else tempStr := 'INACTIVE;';
  1886.         if ListMember.Manager then tempStr := tempStr + 'MANAGER;'
  1887.           else tempStr := tempStr + 'NOMANAGER;';
  1888.         FINI.WriteString('Members', IntToStr(x), tempStr + ListMember.EMail);
  1889.       end;
  1890.       FINI.EraseSection('Pending Members');
  1891.       for x := 0 to FPendingMembers.Count -1 do begin
  1892.         PendingListMember := FPendingMembers[x];
  1893.         tempStr := FloatToStr(PendingListMember.ExpirationDate) + ';';
  1894.         tempStr := tempStr + IntToStr(PendingListMember.MagicNumber) + ';';
  1895.         FINI.WriteString('Pending Members', IntToStr(x),
  1896.                          tempStr + PendingListMember.EMail);
  1897.       end;
  1898.       FINI.EraseSection('Welcome Message');
  1899.       for x := 0 to FSL_Welcome.Count -1 do
  1900.         if Trim(FSL_Welcome[x]) = '' then
  1901.           FINI.WriteString('Welcome Message', IntToStr(x),
  1902.                            '<This line intentionally left blank.>')
  1903.         else
  1904.           FINI.WriteString('Welcome Message', IntToStr(x), FSL_Welcome[x]);
  1905.       FINI.EraseSection('Signature Message');
  1906.       for x := 0 to FSL_Signature.Count -1 do
  1907.         if Trim(FSL_Signature[x]) = '' then
  1908.           FINI.WriteString('Signature Message', IntToStr(x),
  1909.                            '<This line intentionally left blank.>')
  1910.         else
  1911.           FINI.WriteString('Signature Message', IntToStr(x), FSL_Signature[x]);
  1912.       FINI.EraseSection('Farewell Message');
  1913.       for x := 0 to FSL_Farewell.Count -1 do
  1914.         if Trim(FSL_Farewell[x]) = '' then
  1915.           FINI.WriteString('Farewell Message', IntToStr(x),
  1916.                            '<This line intentionally left blank.>')
  1917.         else
  1918.           FINI.WriteString('Farewell Message', IntToStr(x), FSL_Farewell[x]);
  1919.       FINI.WriteString('Security', 'Password', FPassword);
  1920.       FINI.WriteString('General', 'Mail Errors To', FErrorsMailedTo);
  1921.       FINI.WriteString('Auto Files', 'Welcome', FFile_Welcome);
  1922.       FINI.WriteString('Auto Files', 'Signature', FFile_Signature);
  1923.       FINI.WriteString('Auto Files', 'Farewell', FFile_Farewell);
  1924.       FINI.WriteBool('List Behavior', 'Allow Open (Public) Subscription',
  1925.                      FLB_AllowPublicSubscription);
  1926.       FINI.WriteBool('List Behavior', 'Force Replies to List',
  1927.                      FLB_ForceRepliesToList);
  1928.       FINI.WriteBool('List Behavior', 'Do not report List Members to SMTP',
  1929.                      FLB_DoNotReportListMembers_SMTP);
  1930.       FINI.WriteBool('List Behavior', 'Do not report List Exists',
  1931.                      FLB_DoNotReportListExists);
  1932.       FINI.WriteBool('List Behavior', 'Do not report List Members',
  1933.                      FLB_DoNotReportListMembers);
  1934.       FINI.WriteBool('List Behavior', 'Member-Only Submission',
  1935.                      FLB_MemberSubmissionOnly);
  1936.       FINI.WriteString('Digest', 'Filename', FArchiveFile);
  1937.     finally
  1938.       FINI.Free;
  1939.     end;
  1940.     Result := True;
  1941.   except
  1942.     on E: Exception do Result := False;
  1943.   end;
  1944. end;
  1945. (******************************************************************************)
  1946. (*                                                                            *)
  1947. (*  STOP  Mail List Information Object                                        *)
  1948. (*                                                                            *)
  1949. (******************************************************************************)
  1950. (******************************************************************************)
  1951. (*                                                                            *)
  1952. (*  START POP3 User Mail Information Object                                   *)
  1953. (*                                                                            *)
  1954. (******************************************************************************)
  1955. constructor TPop3MailInformation.Create;
  1956. begin
  1957.   inherited Create;
  1958.   FMail := TList.Create;
  1959.   FFolderPath := '';
  1960. end;
  1961. procedure TPop3MailInformation.DropAllMail;
  1962. var
  1963.   x : Longint;
  1964.   MailItem : PPop3MailEntry;
  1965. begin
  1966.   for x := FMail.Count -1 downto 0 do begin
  1967.     MailItem := FMail[x];
  1968.     FreeMem(MailItem, SizeOf(TPop3MailEntry));
  1969.     FMail.Delete(x);
  1970.   end;
  1971. end;
  1972. destructor TPop3MailInformation.Destroy;
  1973. begin
  1974.   DropAllMail;
  1975.   FMail.Free;
  1976.   inherited Destroy;
  1977. end;
  1978. function TPop3MailInformation.GetCount : Longint;
  1979. begin
  1980.   Result := FMail.Count;
  1981. end;
  1982. function TPop3MailInformation.GetDeletedCount : Longint;
  1983. var
  1984.   x, Total : Longint;
  1985.   MailItem : PPop3MailEntry;
  1986. begin
  1987.   Total := 0;
  1988.   for x := 0 to FMail.Count -1 do begin
  1989.     MailItem := FMail[x];
  1990.     if MailItem.MarkForDelete then Inc(Total);
  1991.   end;
  1992.   Result := Total;
  1993. end;
  1994. function TPop3MailInformation.GetByteCount : Longint;
  1995. var
  1996.   x, Total : Longint;
  1997.   MailItem : PPop3MailEntry;
  1998. begin
  1999.   Total := 0;
  2000.   for x := 0 to FMail.Count -1 do begin
  2001.     MailItem := FMail[x];
  2002.     Total := Total + MailItem.FileSize;
  2003.   end;
  2004.   Result := Total;
  2005. end;
  2006. function TPop3MailInformation.GetMailEntry(Index: Integer) : PPop3MailEntry;
  2007. begin
  2008.   Result := nil;
  2009.   if (Index > -1) and (Index < FMail.Count) then Result := FMail[Index];
  2010. end;
  2011. procedure TPop3MailInformation.ReadFolder(UserName : String);
  2012. var
  2013.   FolderPath : String;
  2014.   SearchRec: TSearchRec;
  2015.   SearchResult : Longint;
  2016.   Count : Longint;
  2017.   MailItem : PPop3MailEntry;
  2018. begin
  2019.   FolderPath := INI.MailBoxPath + UserName + '';
  2020.   if DirectoryExists(FolderPath) then begin
  2021.     FFolderPath := FolderPath;
  2022.     DropAllMail;
  2023.     Count := 0;
  2024.     SearchResult := FindFirst(FolderPath + '*.*', faAnyFile, SearchRec);
  2025.     while SearchResult = 0 do begin
  2026.       if (SearchRec.Name <> '.')  and
  2027.          (SearchRec.Name <> '..') and
  2028.          (SearchRec.Name <> '')   and
  2029.          (UpperCase(ExtractFileExt(SearchRec.Name)) <> '.INI') and
  2030.          (not (SearchRec.Attr and faDirectory > 0)) then begin
  2031.         Inc(Count);
  2032.         GetMem(MailItem, SizeOf(TPop3MailEntry));
  2033.         MailItem.Number := Count;
  2034.         MailItem.Filename := SearchRec.Name;
  2035.         MailItem.FileSize := GetFileSize(FolderPath + SearchRec.Name);
  2036.         MailItem.MarkForDelete := False;
  2037.         FMail.Add(MailItem);
  2038.       end;
  2039.       SearchResult := FindNext(SearchRec);
  2040.     end;
  2041.     FindClose(SearchRec);
  2042.   end;
  2043. end;
  2044. function TPop3MailInformation.Find(ID : Integer) : PPop3MailEntry;
  2045. var
  2046.   x : Longint;
  2047.   MailItem : PPop3MailEntry;
  2048. begin
  2049.   Result := nil;
  2050.   for x := 0 to FMail.Count -1 do begin
  2051.     MailItem := FMail[x];
  2052.     if MailItem.Number = ID then Result := FMail[x];
  2053.   end;
  2054. end;
  2055. function TPop3MailInformation.DeleteMarkedMessages : Longint;
  2056. // Return delete count
  2057. var
  2058.   x, Count : Longint;
  2059.   FileLocation : String;
  2060.   MailItem : PPop3MailEntry;
  2061. begin
  2062.   Count := 0;
  2063.   for x := 0 to FMail.Count -1 do begin
  2064.     MailItem := FMail[x];
  2065.     if MailItem.MarkForDelete then begin
  2066.       FileLocation := FFolderPath + MailItem.Filename;
  2067.       if FileExists(FileLocation) and
  2068.          FileOperation(FileLocation, '', 'DELETE') then Inc(Count);
  2069.     end;
  2070.   end;
  2071.   Result := Count;
  2072. end;
  2073. (******************************************************************************)
  2074. (*                                                                            *)
  2075. (*  STOP  POP3 User Mail Information Object                                   *)
  2076. (*                                                                            *)
  2077. (******************************************************************************)
  2078. (******************************************************************************)
  2079. (*                                                                            *)
  2080. (*  START Message Route Object                                                *)
  2081. (*                                                                            *)
  2082. (******************************************************************************)
  2083. constructor TMessageRouteInformation.Create(Kind
  2084.                                             : TMessageRouteInformation_Kind);
  2085. begin
  2086.   inherited Create;
  2087.   FKind := Kind;
  2088.   FHosts := TStringList.Create;
  2089.   Initialize;
  2090. end;
  2091. destructor TMessageRouteInformation.Destroy;
  2092. begin
  2093.   FHosts.Free;
  2094.   inherited Destroy;
  2095. end;
  2096. procedure TMessageRouteInformation.Initialize;
  2097. begin
  2098.   FHosts.Clear;
  2099.   FMailbox := '';
  2100.   FDomain  := '';
  2101. end;
  2102. function TMessageRouteInformation.ParseRoute(Route : String) : Integer;
  2103. // Given a route... populate the internal data structures
  2104. // Return Codes:
  2105. // 0 = Parsed correctly.
  2106. // 1 = route was empty
  2107. // 2 = mismatched brackets <>
  2108. // 3 = mismatched host brackets []
  2109. // 4 = host name didn't start with @
  2110. // 5 = no @ in mailbox specification
  2111. // 6 = bad mailbox quoting ""
  2112. var
  2113.   Error : Integer;
  2114.   LeftBracket, RightBracket : Integer;
  2115.   RouteContents : String;
  2116.   HostList, HostStr : String;
  2117.   BoxandDomain, Mailbox, Domain : String;
  2118. begin
  2119.   // Format:
  2120.   // <@HostA,@[1.2.3.4],@#456:"Mail Box"@Domain>
  2121.   // Return of 0 indicates success...
  2122.   // any other number is a failure of some kind...
  2123.   Error := 0;
  2124.   FHosts.CLear;
  2125.   FDomain := '';
  2126.   FMailbox := '';
  2127.   // may accept non <> bracketed routes!
  2128.   LeftBracket  := Pos('<', Route);
  2129.   RightBracket := Pos('>', Route);
  2130.   if ((LeftBracket = 0) and (RightBracket = 0)) or
  2131.      ((LeftBracket > 0) and (RightBracket > 0)) then begin
  2132.     // Fetch Real Route (no brackets)
  2133.     if LeftBracket = 0 then RouteContents := Trim(Route)
  2134.       else begin
  2135.         RouteContents := Trim(Copy(Route, Pos('<', Route) +1, Length(Route)));
  2136.         RouteContents := Trim(Copy(RouteContents, 1,
  2137.                                    Pos('>', RouteContents) -1));
  2138.       end;
  2139.     if RouteContents = '' then begin
  2140.       Error := 1;
  2141.     end else begin
  2142.       // Seperate out hosts
  2143.       if Pos(':', RouteContents) > 0 then begin
  2144.         // There are hosts and a Mailbox at a domain...
  2145.         BoxandDomain := Trim(Copy(RouteContents, Pos(':', RouteContents) +1,
  2146.                                                      Length(RouteContents)));
  2147.         // This part is the mailbox and domain
  2148.         HostList := Trim(Copy(RouteContents, 1, Pos(':', RouteContents) -1));
  2149.         // This part is the comma seperated host list
  2150.         // If we add a comma to the end, we can process while there are commas
  2151.         // cute idea, huh?
  2152.         HostList := HostList + ',';
  2153.         while Pos(',', HostList) > 0 do begin
  2154.           HostStr := Trim(Copy(HostList, 1, Pos(',', HostList) -1));
  2155.           HostList := Trim(Copy(HostList, Pos(',', HostList) +1,
  2156.                                           Length(HostList)));
  2157.           // must strip @ off...
  2158.           if Pos('@', HostStr) = 1 then begin
  2159.             HostStr := Trim(Copy(HostStr, 2, Length(HostStr)));
  2160.             if Copy(HostStr, 1, 1) = '#' then begin
  2161.               // The host is specified as a machine number...
  2162.               // when does this happen on the internet?
  2163.               HostStr := Trim(Copy(HostStr, 2, Length(HostStr)));
  2164.             end else
  2165.             if (Pos('[', HostStr) > 0) or (Pos(']', HostStr) > 0) then begin
  2166.               // The host is specified as a dotted IP address that we do not
  2167.               // desolve... we just contact directly.  Woo-hoo!
  2168.               if Copy(HostStr, 1, 1) = '[' then begin
  2169.                 if Copy(HostStr, Length(HostStr), 1) = ']' then begin
  2170.                   // Here's our host Domain name
  2171.                   HostStr := Trim(Copy(HostStr, 2, Length(HostStr) -2));
  2172.                 end else begin
  2173.                   // This could be right... but we have a host bracket problem
  2174.                   HostStr := Trim(Copy(HostStr, 2, Length(HostStr) -1));
  2175.                   Error := 3;  // bad host bracketing
  2176.                 end;
  2177.               end else begin
  2178.                 // We have a host bracket problem
  2179.                 Error := 3;
  2180.               end;
  2181.             end;
  2182.             if HostStr <> '' then FHosts.Add(HostStr);
  2183.           end else Error := 4;  // Host name doesn't start with an @
  2184.         end;
  2185.       end else BoxandDomain := RouteContents;
  2186.       // Find Domain and mailbox
  2187.       if Pos('@', BoxandDomain) > 0 then begin
  2188.         Mailbox := Trim(Copy(BoxandDomain, 1, Pos('@', BoxandDomain) -1));
  2189.         Domain := Trim(Copy(BoxandDomain, Pos('@', BoxandDomain) +1,
  2190.                                               Length(BoxandDomain)));
  2191.         // Mailbox first
  2192.         if Pos('"', Mailbox) > 0 then begin
  2193.           if Copy(Mailbox, 1, 1) = '"' then begin
  2194.             if Copy(Mailbox, Length(Mailbox), 1) = '"' then begin
  2195.               Mailbox := Trim(Copy(Mailbox, 2, Length(Mailbox) -2));
  2196.             end else begin
  2197.               Mailbox := Trim(Copy(Mailbox, 2, Length(Mailbox) -1));
  2198.               Error := 6;  // bad mailbox quoting
  2199.             end;
  2200.             FMailbox := Mailbox;
  2201.           end else begin
  2202.             Error := 6; // bad mailbox quoting
  2203.           end;
  2204.         end else begin
  2205.           FMailbox := Mailbox;
  2206.         end;
  2207.         // Domain
  2208.         HostStr := Domain;
  2209.         if Copy(HostStr, 1, 1) = '#' then begin
  2210.           // The host is specified as a machine number...
  2211.           // when does this happen on the internet?
  2212.           HostStr := Trim(Copy(HostStr, 2, Length(HostStr)));
  2213.         end else
  2214.         if (Pos('[', HostStr) > 0) or (Pos(']', HostStr) > 0) then begin
  2215.           // The host is specified as a dotted IP address that we do not
  2216.           // desolve... we just contact directly.  Woo-hoo!
  2217.           if Copy(HostStr, 1, 1) = '[' then begin
  2218.             if Copy(HostStr, Length(HostStr), 1) = ']' then begin
  2219.               // Here's our host Domain name
  2220.               HostStr := Trim(Copy(HostStr, 2, Length(HostStr) -2));
  2221.             end else begin
  2222.               // This could be right... but we have a host bracket problem
  2223.               HostStr := Trim(Copy(HostStr, 2, Length(HostStr) -1));
  2224.               Error := 3;  // bad host bracketing
  2225.             end;
  2226.           end else begin
  2227.             // We have a host bracket problem
  2228.             Error := 3;
  2229.           end;
  2230.         end;
  2231.         FDomain := HostStr;
  2232.       end else begin
  2233.         // Mailbox wasn't seperated from domain by @
  2234.         Error := 5; // no mailbox (x@y)
  2235.       end;
  2236.     end;
  2237.   end else begin
  2238.     // the route had mis-matched <> brackets
  2239.     Error := 2;
  2240.   end;
  2241.   Result := Error;
  2242. end;
  2243. function TMessageRouteInformation.BuildRoute : String;
  2244. // Construct a route from the internal data structures
  2245. var
  2246.   x : Longint;
  2247.   tempStr, HostStr : String;
  2248. begin
  2249.   tempStr := '<';
  2250.   // Hosts
  2251.   for x := 0 to FHosts.Count -1 do begin
  2252.     HostStr := FormatedAtDomain(FHosts[x]);
  2253.     if HostStr <> '' then
  2254.       if x < FHosts.Count -1 then tempStr := tempStr + HostStr + ','
  2255.         else tempStr := tempStr + HostStr + ':'
  2256.   end;
  2257.   // Mailbox and Domain
  2258.   if (FMailbox <> '') and (FDomain <> '') then
  2259.     tempStr := tempStr + FormatedAddress(FMailbox, FDomain);
  2260.   tempStr := tempStr + '>';
  2261.   Result := tempStr;
  2262. end;
  2263. (******************************************************************************)
  2264. (*                                                                            *)
  2265. (*  STOP  Message Route Object                                                *)
  2266. (*                                                                            *)
  2267. (******************************************************************************)
  2268. (******************************************************************************)
  2269. (*                                                                            *)
  2270. (*  START Window Handle Component Object                                      *)
  2271. (*                                                                            *)
  2272. (* This Object is just a TComponent but with a Window Handle so we can post   *)
  2273. (* Windows Messages to it.  It fires an event for ALL Windows Messages so we  *)
  2274. (* can see what we were sent.  The Windows Handle code is lifted straight     *)
  2275. (* from Francois' code to generate a handle for the TWSocket component        *)
  2276. (*                                                                            *)
  2277. (******************************************************************************)
  2278. // This stuff is necessary to register a windows class and create a window
  2279. // all so I can have a windows handle for getting a message!
  2280. function WHComponentWindowProc(hWindow : HWND;   aMessage : Integer;
  2281.                                  wParam  : WPARAM; lParam   : LPARAM)
  2282.                                  : Integer; stdcall;
  2283. var
  2284.     Obj    : TWHComponent;
  2285.     MsgRec : TMessage;
  2286. begin
  2287.   { GetWindowLong is retrieving info we asked it to store with SetWindowLong }
  2288.   { in the WindowClass.cbWndExtra when we registered.  We stored the Object  }
  2289.   { ID for the object. That way, we could fetch it here and use it for       }
  2290.   { windows message handling!                                                }
  2291.   Obj := TWHComponent(GetWindowLong(hWindow, 0));
  2292.   if not Assigned(Obj) then begin
  2293.     Result := DefWindowProc(hWindow, aMessage, wParam, lParam);
  2294.   end else begin
  2295.     { Delphi use a TMessage type to pass paramter to his own kind of    }
  2296.     { windows procedure. So we are doing the same...                    }
  2297.     if aMessage <> 0 then begin
  2298.       MsgRec.Msg    := aMessage;
  2299.       MsgRec.wParam := wParam;
  2300.       MsgRec.lParam := lParam;
  2301.       Obj.WinProc(MsgRec);
  2302.       Result := MsgRec.Result;
  2303.     end;
  2304.   end;
  2305. end;
  2306. function TWHComponent.GetWindowHandle(Obj : TObject) : HWnd;
  2307. const
  2308.   ComponentName = 'WHComponentWindowClass';
  2309. var
  2310.   WindowClass : TWndClass;
  2311. begin
  2312.   // can't re-register a class, so you gotta check if it's already registered!
  2313.   if not GetClassInfo(HInstance, ComponentName, WindowClass) then begin
  2314.     WindowClass.Style := 0;
  2315.     WindowClass.lpfnWndProc := @WHComponentWindowProc;
  2316.     WindowClass.cbClsExtra := 0;
  2317.     WindowClass.cbWndExtra := SizeOf(Pointer);
  2318.     { This is where we'll store a reference to the created object            }
  2319.     WindowClass.hInstance := HInstance;
  2320.     WindowClass.hIcon := 0;
  2321.     WindowClass.hCursor := 0;
  2322.     WindowClass.hbrBackground := 0;
  2323.     WindowClass.lpszMenuName := nil;
  2324.     WindowClass.lpszClassName := ComponentName;
  2325.     if Windows.RegisterClass(WindowClass) <> 0 then
  2326.     Result := CreateWindowEx(WS_EX_TOOLWINDOW,
  2327.                              ComponentName,
  2328.                              '',       {window name}
  2329.                              WS_POPUP, {window style}
  2330.                              0, 0,     {X, Y}
  2331.                              0, 0,     {Width, Height}
  2332.                              0,        {hWndParent}
  2333.                              0,        {hMenu}
  2334.                              HInstance,{hInstance}
  2335.                              nil)      {CreateParam}
  2336.     else Result := 0;
  2337.     if Result <> 0 then SetWindowLong(Result, 0, Integer(Obj));
  2338.     { Here we actually store the new object's handle...}
  2339.     { Necessary for handling of the windows messages   }
  2340.   end else begin
  2341.     Result := CreateWindowEx(WS_EX_TOOLWINDOW,
  2342.                              ComponentName,
  2343.                              '',       {window name}
  2344.                              WS_POPUP, {window style}
  2345.                              0, 0,     {X, Y}
  2346.                              0, 0,     {Width, Height}
  2347.                              0,        {hWndParent}
  2348.                              0,        {hMenu}
  2349.                              HInstance,{hInstance}
  2350.                              nil);      {CreateParam}
  2351.     if Result <> 0 then SetWindowLong(Result, 0, Integer(Obj));
  2352.     { Here we actually store the new object's handle...}
  2353.     { Necessary for handling of the windows messages   }
  2354.   end;
  2355. end;
  2356. procedure TWHComponent.WinProc(var Msg: TMessage);
  2357. begin
  2358.   if Assigned(FWindowsMessage) then OnWindowsMessage(Self, Msg);
  2359. end;
  2360. constructor TWHComponent.Create(AOwner: TComponent);
  2361. var
  2362.   x : integer;
  2363. begin
  2364.   inherited Create(AOwner);  // Get our Window Handle
  2365.   FHandle := GetWindowHandle(Self);
  2366.   if FHandle = 0 then begin
  2367.     // Error getting handle... InttoStr(GetLastError)
  2368.   end;
  2369. end;
  2370. destructor TWHComponent.Destroy;
  2371. begin
  2372.   DestroyWindow(FHandle);  // destroy our Window Handle
  2373.   inherited destroy;
  2374. end;
  2375. (******************************************************************************)
  2376. (*                                                                            *)
  2377. (*  STOP  Window Handle Component Object                                      *)
  2378. (*                                                                            *)
  2379. (******************************************************************************)
  2380. function IsNameValid(Name : String) : Boolean;
  2381. // Is a User, List or Alias name valid?
  2382. begin
  2383.   Result := True;
  2384.   if Pos('(', Name) > 0 then Result := False;
  2385.   if Pos(')', Name) > 0 then Result := False;
  2386.   if Pos('<', Name) > 0 then Result := False;
  2387.   if Pos('>', Name) > 0 then Result := False;
  2388.   if Pos('@', Name) > 0 then Result := False;
  2389.   if Pos(',', Name) > 0 then Result := False;
  2390.   if Pos(';', Name) > 0 then Result := False;
  2391.   if Pos(':', Name) > 0 then Result := False;
  2392.   if Pos('', Name) > 0 then Result := False;
  2393.   if Pos('"', Name) > 0 then Result := False;
  2394.   if Pos('[', Name) > 0 then Result := False;
  2395.   if Pos(']', Name) > 0 then Result := False;
  2396. end;
  2397. function IsNameValidIncludingAt(Name : String) : Boolean;
  2398. // Just for Aliases that can include FQ mailboxes...
  2399. begin
  2400.   Result := True;
  2401.   if Pos('(', Name) > 0 then Result := False;
  2402.   if Pos(')', Name) > 0 then Result := False;
  2403.   if Pos('<', Name) > 0 then Result := False;
  2404.   if Pos('>', Name) > 0 then Result := False;
  2405.   if Pos(',', Name) > 0 then Result := False;
  2406.   if Pos(';', Name) > 0 then Result := False;
  2407.   if Pos(':', Name) > 0 then Result := False;
  2408.   if Pos('', Name) > 0 then Result := False;
  2409.   if Pos('"', Name) > 0 then Result := False;
  2410.   if Pos('[', Name) > 0 then Result := False;
  2411.   if Pos(']', Name) > 0 then Result := False;
  2412. end;
  2413. function StatusLevelDescription(Level : Integer) : String;
  2414. begin
  2415.   case Level of
  2416.     STAT_CRITICALERROR   : Result := 'Critical Errors';
  2417.     STAT_SERVERERROR     : Result := 'Server Errors';
  2418.     STAT_SERVEREVENT     : Result := 'Server Events';
  2419.     STAT_CONNECTIONERROR : Result := 'Connection Errors';
  2420.     STAT_CONNECTIONEVENT : Result := 'Connection Events';
  2421.     STAT_COMMANDERROR    : Result := 'Command Errors';
  2422.     STAT_COMMANDEVENT    : Result := 'Command Events';
  2423.   end;
  2424. end;
  2425. end.