Settings_SmtpServer.pas
上传用户:dh8233980
上传日期:2014-10-16
资源大小:1015k
文件大小:8k
- unit Settings_SmtpServer;
- (******************************************************************************)
- (* *)
- (* Hermes Smtp Server Settings Dialog Box *)
- (* Part of Hermes SMTP/POP3 Server. *)
- (* Copyright(C) 2000 by Alexander J. Fanti, All Rights Reserver Worldwide. *)
- (* *)
- (* Created January 10, 2000 by Alexander J. Fanti. See License.txt *)
- (* *)
- (* Used by: Main *)
- (* Uses: DataU1, WSocket *)
- (* *)
- (* Description: This Modal dialog window allows the user to change Smtp *)
- (* server settings *)
- (* *)
- (* Revisions: 1/21/2000 AJF Commented *)
- (* 2/12/2000 AJF Added Interface to manage Smtp Server access *)
- (* control (for anti-spam) *)
- (* 2/13/2000 AJF Re-worked interface for new, more intuitive *)
- (* controls *)
- (* *)
- (******************************************************************************)
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, Buttons, Spin, FileCtrl, ShellAPI, ShlObj, ComObj, Menus,
- ComCtrls;
- type
- TfrmSettings_SmtpServer = class(TForm)
- btnOK: TBitBtn;
- btnCancel: TBitBtn;
- popupDomains: TPopupMenu;
- puDomainsAdd: TMenuItem;
- puDomainsDelete: TMenuItem;
- PageControl1: TPageControl;
- tsGeneral: TTabSheet;
- Label2: TLabel;
- lstAddress: TComboBox;
- spePort: TSpinEdit;
- Label3: TLabel;
- Label5: TLabel;
- Label4: TLabel;
- lstDomains: TListBox;
- popupAcceptedDomains: TPopupMenu;
- pu_AcceptedDomains_Add: TMenuItem;
- pu_AcceptedDomains_Delete: TMenuItem;
- tsAccess2: TTabSheet;
- btnBanning: TButton;
- GroupBox1: TGroupBox;
- cbxRestrictAccess: TCheckBox;
- lblNoRelayOff: TLabel;
- lblNoRelayOn: TLabel;
- Label1: TLabel;
- lstAcceptedDomains: TListBox;
- Label7: TLabel;
- Label8: TLabel;
- Label6: TLabel;
- Label9: TLabel;
- lblConnectionInactivityTimeout: TLabel;
- speInactivityTimeout: TSpinEdit;
- procedure FormShow(Sender: TObject);
- procedure btnOKClick(Sender: TObject);
- procedure puDomainsAddClick(Sender: TObject);
- procedure puDomainsDeleteClick(Sender: TObject);
- procedure popupDomainsPopup(Sender: TObject);
- procedure pu_AcceptedDomains_AddClick(Sender: TObject);
- procedure pu_AcceptedDomains_DeleteClick(Sender: TObject);
- procedure popupAcceptedDomainsPopup(Sender: TObject);
- procedure cbxRestrictAccessClick(Sender: TObject);
- procedure btnBanningClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmSettings_SmtpServer: TfrmSettings_SmtpServer;
- implementation
- uses DataU1, WSocket, Settings_SmtpServerAccessControl;
- {$R *.DFM}
- procedure TfrmSettings_SmtpServer.FormShow(Sender: TObject);
- var
- x : Longint;
- begin
- PageControl1.ActivePage := tsGeneral;
- // General Tab
- // List available IP addresses (or ANY)
- lstAddress.Clear;
- lstAddress.Items.Add('*** Any ***');
- for x := 0 to LocalIPList.Count -1 do
- lstAddress.Items.Add(LocalIPList[x]);
- // Populate Dialog with Setting Information
- lstAddress.ItemIndex := 0;
- for x := 0 to lstAddress.Items.Count -1 do
- if INI.Smtp_BindAddress = lstAddress.Items[x] then
- lstAddress.ItemIndex := x;
- spePort.Value := INI.Smtp_Port;
- speInactivityTimeout.Value := INI.Smtp_InactivityTimeout;
- lstDomains.Clear;
- for x := 0 to INI.Smtp_Domains.Count -1 do
- lstDomains.Items.Add(INI.Smtp_Domains[x]);
- // Access Control Tab
- lstAcceptedDomains.Clear;
- for x := 0 to INI.Smtp_Access_AcceptedDomains.Count -1 do
- lstAcceptedDomains.Items.Add(INI.Smtp_Access_AcceptedDomains[x]);
- cbxRestrictAccess.Checked := INI.Smtp_Access_Restricted;
- lblNoRelayOff.Visible := not cbxRestrictAccess.Checked;
- lblNoRelayOn.Visible := cbxRestrictAccess.Checked;
- end;
- procedure TfrmSettings_SmtpServer.btnOKClick(Sender: TObject);
- begin
- // Retrieve Settings from Dialog
- // Save General Settings
- if lstAddress.ItemIndex = 0 then INI.Smtp_BindAddress := '0.0.0.0'
- else INI.Smtp_BindAddress := lstAddress.Items[lstAddress.ItemIndex];
- INI.Smtp_Port := spePort.Value;
- INI.Smtp_InactivityTimeout := speInactivityTimeout.Value;
- INI.SetSmtp_Domains(lstDomains.Items);
- // Save Access Control
- INI.SetSmtp_Access_AcceptedDomains(lstAcceptedDomains.Items);
- INI.Smtp_Access_Restricted := cbxRestrictAccess.Checked
- end;
- procedure TfrmSettings_SmtpServer.popupDomainsPopup(Sender: TObject);
- begin
- // Enable Domain list popum menu items
- puDomainsDelete.Enabled := lstDomains.SelCount > 0;
- end;
- procedure TfrmSettings_SmtpServer.puDomainsAddClick(Sender: TObject);
- var
- NewDomain : String;
- x : Longint;
- Found : Boolean;
- begin
- // Add a new domain to the Domains list
- NewDomain := Trim(InputBox('Add Local Domain', 'Domain', ''));
- if NewDomain <> '' then begin
- Found := False;
- for x := 0 to lstDomains.Items.Count -1 do
- if LowerCase(NewDomain) = LowerCase(lstDomains.Items[x]) then
- Found := True;
- if not Found then lstDomains.Items.Add(NewDomain);
- end;
- end;
- procedure TfrmSettings_SmtpServer.puDomainsDeleteClick(Sender: TObject);
- var
- x : Longint;
- begin
- // remove domains from the domain list
- for x := lstDomains.Items.Count -1 downto 0 do
- if lstDomains.Selected[x] then lstDomains.Items.Delete(x);
- end;
- procedure TfrmSettings_SmtpServer.popupAcceptedDomainsPopup(
- Sender: TObject);
- begin
- // Enable Domain list popum menu items
- pu_AcceptedDomains_Delete.Enabled := lstAcceptedDomains.SelCount > 0;
- end;
- procedure TfrmSettings_SmtpServer.pu_AcceptedDomains_AddClick(
- Sender: TObject);
- var
- NewDomain : String;
- x : Longint;
- Found : Boolean;
- begin
- // Add a new domain to the Domains list
- NewDomain := Trim(InputBox('Add Accepted Domain', 'Domain', ''));
- if NewDomain <> '' then begin
- Found := False;
- for x := 0 to lstAcceptedDomains.Items.Count -1 do
- if LowerCase(NewDomain) = LowerCase(lstAcceptedDomains.Items[x]) then
- Found := True;
- if not Found then lstAcceptedDomains.Items.Add(NewDomain);
- end;
- end;
- procedure TfrmSettings_SmtpServer.pu_AcceptedDomains_DeleteClick(
- Sender: TObject);
- var
- x : Longint;
- begin
- // remove domains from the domain list
- for x := lstAcceptedDomains.Items.Count -1 downto 0 do
- if lstAcceptedDomains.Selected[x] then lstAcceptedDomains.Items.Delete(x);
- end;
- procedure TfrmSettings_SmtpServer.cbxRestrictAccessClick(Sender: TObject);
- begin
- lblNoRelayOff.Visible := not cbxRestrictAccess.Checked;
- lblNoRelayOn.Visible := cbxRestrictAccess.Checked;
- end;
- procedure TfrmSettings_SmtpServer.btnBanningClick(Sender: TObject);
- begin
- frmSettings_SmtpServerAccessControl.ShowModal;
- end;
- end.