-
Notifications
You must be signed in to change notification settings - Fork 0
/
TCP EMail Checker.au3
87 lines (81 loc) · 3.26 KB
/
TCP EMail Checker.au3
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
83
84
85
86
87
Opt('TrayIconDebug', 1)
GUICreate('CheckMail', 300, 200)
$status = GUICtrlCreateEdit('Initiating...', 5, 5, 290, 190)
GUISetState()
TCPStartup()
$ip = TCPNameToIP('emirates.net.ae')
$user = InputBox('Username', 'Username (don''t forget @domain):', '', '', 200, 150)
$pass = InputBox('Password', 'Password for ' & $user & ':', '', '*', 200, 150)
$socket = TCPConnect($ip, 110)
If $socket = -1 Then
GUICtrlSetData($status, 'Error: Bad connection' & @CRLF)
Else
$step = 'login'
Do
$recv = TCPRecv($socket, 512)
If @error Then
GUICtrlSetData($status, 'Notice: Disconnected!' & @CRLF, 1)
$socket = -1
ElseIf StringInStr($recv, '+OK') = 1 Then
GUICtrlSetData($status, $recv & @CRLF, 1)
Switch $step
Case 'login'
GUICtrlSetData($status, 'Login: Username...' & @CRLF, 1)
_TCPSend($socket, 'user ' & $user & @CRLF)
$step = 'pass'
Case 'pass'
GUICtrlSetData($status, 'Login: Password...' & @CRLF, 1)
_TCPSend($socket, 'pass ' & $pass & @CRLF)
$step = 'stat'
Case 'stat'
GUICtrlSetData($status, 'Logged In: Check for mail...' & @CRLF, 1)
_TCPSend($socket, 'stat' & @CRLF)
$step = 'check'
Case 'check'
$match = StringRegExp($recv, '\+OK ([0-9]+)', 2)
If Not @error Then
GUICtrlSetData($status, 'Success: There are ' & $match[1] & ' email(s) in the inbox' & @CRLF, 1)
_TCPSend($socket, 'RETR 1")
$step = 'read'
Else
GUICtrlSetData($status, 'Disconnecting', 1)
TCPCloseSocket($socket)
$socket = -1
EndIf
Case 'read'
Local $Header = "", $Body = "", $recv = ""
; Header
While $recv = ""
$recv &= TCPRecv($socket, 512)
Sleep(10)
WEnd
$Header = $recv
$recv = ""
; Body
While $recv = ""
$recv &= TCPRecv($socket, 512)
Sleep(10)
WEnd
$Body = $recv
; You'll have to work out others
$recv = $sBackup & @CRLF & $recv
GUICtrlSetData($status, 'Email #1 content:' & @CRLF & '----------' & @CRLF & $recv & @CRLF & '----------' & @CRLF, 1)
GUICtrlSetData($status, 'Disconnecting', 1)
TCPCloseSocket($socket)
$socket = -1
Exit
EndSwitch
ElseIf StringInStr($recv, '-ERR') = 1 Then
GUICtrlSetData($status, 'Error: ' & $recv & @CRLF, 1)
GUICtrlSetData($status, 'Disconnecting', 1)
TCPCloseSocket($socket)
$socket = -1
EndIf
Until $socket = -1
EndIf
Do
Until GUIGetMsg() = -3
Func _TCPSend($socket, $data)
TCPSend($socket, $data)
GUICtrlSetData($status, '> ' & $data, 1)
EndFunc