This repository has been archived by the owner on May 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
sendmail.dpr
82 lines (72 loc) · 1.68 KB
/
sendmail.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
program sendmail;
uses
SysUtils, Windows, WinSock, common;
var
mFrom,mTo,mSubj,mSMTP,mBody,mReturn:string;
full:string;
W:TWSAData;
mysock:TSocket;
T:TSockAddrIn;
ar:array[1..256] of char;
len:longword;
F:TextFile;
s:string;
procedure waitResponse;
var
s:string;
c:char;
begin
c := #0;
s := '';
while c <> #10 do begin
if recv(mysock,c,1,0) > 0 then s := s + c else begin
outFile('mailfail.txt');
halt(1);
end;
end;
end;
procedure doit(s:string);
begin
s := s + #13#10;
len := length(s);
send(mysock,s[1],len,0);
waitResponse;
end;
begin
mFrom := getValue('from');
mTo := getValue('to');
mSubj := getValue('subject');
mSMTP := getValue('smtp');
mBody := getValue('body');
mReturn := getValue('return');
WSAStartup($101, W);
mysock := socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if mysock = INVALID_SOCKET then begin
outFile('mailfail.txt');
exit;
end;
T.sin_family := PF_INET;
T.sin_addr.s_addr := inet_addr(strpcopy(@ar,mSMTP));
T.sin_port := htons(25);
if connect(mysock, T, SizeOf(T)) = 0 then begin
waitResponse;
doit('HELO sourtimes');
doit('MAIL FROM: '+mFrom);
doit('RCPT TO: '+mTo);
doit('DATA');
doit('Subject: '+mSubj+#13#10+
'X-Mailer: SourTimes Atraksiyonlu CGI Mail Gondericisi v0.1 - (c) SSG ''99'#13#10+
#13#10+mBody+#13#10#13#10+'.'#13#10);
doit(#13#10'QUIT');
closesocket(mysock);
end;
WSACleanup;
AssignFile(F,'mailsuc.txt');
Reset(F);
while not Eof(F) do begin
Readln(F,s);
s := Replace(s,'%return',mReturn);
writeln(s);
end;
CloseFile(F);
end.