|
|
|
CrtSock, SysUtils, Windows; | |
type TAByte = array [0..maxInt-1] of byte; | |
TPAByte = ^TAByte; | |
sHost, sFrom, sTo, sCc, sType, sSubject, sBody, | |
function Encode(data:string) : string; overload; | |
const b64 : array [0..63] of char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | |
ic,len : integer; | |
pi, po : TPAByte; | |
SetLength(result, ((len + 2) div 3) * 4); | |
for ic := 1 to len div 3 do | |
c1 := pi^[0] shl 16 + pi^[1] shl 8 + pi^[2]; | |
po^[0] := byte(b64[(c1 shr 18) and $3f]); | |
po^[1] := byte(b64[(c1 shr 12) and $3f]); | |
po^[2] := byte(b64[(c1 shr 6) and $3f]); | |
po^[3] := byte(b64[(c1 ) and $3f]); | |
inc(dword(po), 4); | |
inc(dword(pi), 3); | |
c1 := pi^[0] shl 16; | |
po^[0] := byte(b64[(c1 shr 18) and $3f]); | |
po^[1] := byte(b64[(c1 shr 12) and $3f]); | |
po^[2] := byte('='); | |
po^[3] := byte('='); | |
end; | |
c1 := pi^[0] shl 16 + pi^[1] shl 8; | |
po^[0] := byte(b64[(c1 shr 18) and $3f]); | |
po^[1] := byte(b64[(c1 shr 12) and $3f]); | |
po^[2] := byte(b64[(c1 shr 6) and $3f]); | |
po^[3] := byte('='); | |
end; | |
procedure Wait(code:char); | |
procedure Echo(s:string); | |
function Include(FileName: string): string; | |
s, res: string; | |
assignfile (f, FileName); | |
readln (f, s); | |
res := res + s; | |
procedure SendMail (tHost, ToA, FromA, tCc, Subject, Body, Attachment, | |
Login, Password, Session: string); | |
sHost := tHost; | |
sFrom := FromA; | |
sSubject:= Subject; | |
sBody := Body+#13+Include(Attachment); | |
host:=CallServer(sHost,25); | |
if host=-1 then | |
while host = -1 do | |
host:=CallServer(sHost,25); | |
sleep (5000); | |
sleep (1000); | |
AssignCrtSock(host,sin,sout); | |
sleep (1000); | |
Echo('EHLO '+Session); | |
sleep (1000); | |
Echo('RSET'); | |
sleep (1000); | |
Echo('AUTH LOGIN'); | |
sleep (1000); | |
Echo(encode(Login)); | |
sleep (1000); | |
Echo(encode(Password)); | |
sleep (1000); | |
Echo('MAIL From:<'+sFrom+'>'); | |
sleep (1000); | |
Echo('RCPT To:<'+sTo+'>'); | |
sleep (1000); | |
Echo('DATA'); | |
sleep (1000); | |
Echo('From: '+sFrom); | |
sleep (1000); | |
Echo('To: '+sTo); | |
sleep (1000); | |
if sCc<>'' then Echo('Cc: '+sCc); | |
if sType<>'' then Echo('MIME-Version: 1.0'#13#10'Content-Type: '+sType+';'#13#10#9'boundary="'+boundary+'"'); | |
Echo('Subject: '+sSubject+#13#10); | |
sleep (1000); | |
WriteLn(sout,sBody); | |
sleep (1000); | |
if sType<>'' then Echo(#13#10'--'+boundary+'--'#13#10); | |
sleep (1000); | |
Echo('QUIT'); | |
Close(Input); | |