Nit umain;
Interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, Menus, Psock, NMsmtp, ExtCtrls, ComCtrls; const BaseTable: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 / ='; type TForm1 = class (TForm ) procedure BitBtn1Click (Sender: TObject); procedure FormCreate (Sender: TObject); procedure BitBtn2Click (Sender: TObject); procedure Button1Click (Sender: TObject); procedure NMSMTP1Connect (Sender: TObject); procedure NMSMTP1Failure (Sender: TObject); procedure NMSMTP1SendStart (Sender: TObject); procedure NMSMTP1Success (Sender: TObject); procedure SpeedButton1Click (Sender: TObject); procedure FormClose (Sender: TObject; var Action: TCloseAction); private {Private declarations} public {public declarations} end;
Var Form1: TFORM1; AuthSucc: Boolean; / / Do you need a password verification?
{$ R * .dfm}
Function EncodeBase64 (Source: String): String; Var Times, Lensrc, I: Integer; X1, X2, X3, X4: Char; XT: Byte; Begin Result: = '; Lensrc: = Length (Source); if Lensrc MOD 3 = 0 THEN TIMES: = Lensrc Div 3 Else Times: = Lensrc Div 3 1; for i: = 0 to Times-1 Do Begin if Lensrc> = (3 i * 3) THEN BEGIN X1: = BaseTable [ (ORD (Source [1 I * 3]) SHR 2) 1]; XT: = (ORD (Source [1 I * 3]) SHL 4) and 48; xt: = x = or (ORD (Source 2 i * 3]) SHR 4); x2: = basetable [xt 1]; XT: = (ORD (Source [2 I * 3]) SHL 2) and 60; xt: = xt OR (ORD) Source [3 I * 3]) SHR 6); x3: = baseable [xt: = (ORD (Source [3 i * 3]) and 63); x4: = basetable [xt 1 ]; ELSE IF LENSRC> = (2 i * 3) Then Begin x1: = BaseTable [(ORD (Source [1 I * 3]) SHR 2) 1]; XT: = (ORD (Source [1 i * 3]) SHL 4) and 48; XT: = xt other (ORD (Source [2 i * 3]) SHR 4); x2: = basetable [xt 1]; xt: = (ORD (Source [2 i * 3]) SHL 2) and 60; x3: = basetable [x 1]; x4: = '='; end else begin x1: = baseteable [(ORD (Source [1 i * 3] ) SHR 2) 1]; XT: = (ORD (Source [1 I * 3]) SHL 4) and 48; x2: = baseteable [xt 1]; x3: = '='; x4: = '='; END; Result: = RESULT X1 X2 X3 X4; END;
Procedure tform1.bitbtn1click (sender: TOBJECT); begin nmsmtp1.host: = Edit1.Text; // mail server host name, send mail server NMSMTP1.Port: = start (EDIT6.TEXT); // SMTP port number, lack The province is 25, the POP3 port number is 110 nmsmtp1.userid: = Edit11.Text; // User ID NMSMTP1.POSTMESSAGE.FROMNAME: = Edit8.Text; // Send the mail host name statusbar1.panels [1] .text: = ' I am connected to the mail server! '; If not nmsmtp1.connected then nmsmtp1.connect; // Connect NMSMTP1.POSTMESSAGE.FROMADDRESS: = Edit7.Text; // sender address nmsmtp1.postMessage.ToadDress.Text: = Edit2.Text; // Recipient address nmsmtp1.postmessage.tocarboncopy.text: = Edit3.text; // Cc NMSMTP1.POSTMESSAGE.BODY.TEXT: = MEMO1.TEXT; // message content nmsmtp1.postMessage.Subject: = Edit4.Text ; // message headline if edit5.text <> '' Then nmsmtp1.postMessage.attachments.add (edit5.text); // message attachment nmsmtp1.sendmail; // Send mail showMessage ('email success!'); END Procedure TFORM1.FormCreate (Sender: TOBJECT); beginpanel1.visible: = false;
Procedure TFORM1.BITBTN2CLICK (Sender: TOBJECT); beginpanel1.visible: = true;
Procedure tForm1.button1click (sender: TOBJECT); beginpanel1.visible: = false;
procedure TForm1.NMSMTP1Connect (Sender: TObject); begin if nmsmtp1.ReplyNumber = 250 then nmsmtp1.Transaction ( 'auth login'); // start authentication if nmsmtp1.ReplyNumber = 334 then // begin after the user name input BASE64 encoding if Length (Edit9.Text)> 0 THEN NMSMTP1.TRANSAction (eDit9.text)); // User name end; if nmsmtp1.replynumber = 334 THEN // Enter the user password after Base64 encoded Begin if Length (Edit10 .Text)> 0 THEN NMSMTP1.TRANSAACTION (ENCODEBASE64 (Edit10.Text)); // Password end; if nmsmtp1.replynumber = 235 dam authssucc: = true;
procedure TForm1.NMSMTP1Failure (Sender: TObject); begin StatusBar1.Panels [1] .Text: = 'Send error!'; end; procedure TForm1.NMSMTP1SendStart (Sender: TObject); begin StatusBar1.Panels [1] .Text: = 'Email is sending ...'; end;
Procedure tform1.nmsmtp1success; begin statusbar1.panels [1] .text: = 'email delivery success!'; end;
Procedure tform1.speedButton1Click (Sender: TOBJECT); beginif OpenDialog1.execute1 Edit5.Text: = OPENDIALOG1.FILENAME; END;
Procedure TForm1.FormClose (Sender: TpoBject; var Action: Tclosection); beginif nmsmtp1.connected; nmsmtp1.disconnect; action: = CAFREE;
End.