forked from LasVegasCoder/Socket-Programming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
92 lines (67 loc) · 1.91 KB
/
index.php
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
88
89
90
91
92
<?php
/**
* This is an example of how to connect to your local email server.
* The variables set in the class should be adjusted to your own environment
*
*
*/
define('PRINCE_SOCKET', 'active');
include("PrinceSocket.Class.php");
/*
function reqHandler($request, $id)
{
if (1 === preg_match('/quit|exit/i', $request)) {
return null;
}
if (1 === preg_match('/stop|halt/i', $request)) {
return false;
}
echo sprintf('*** Got "%s" from %d', $request, $id) . PHP_EOL;
return $request . PHP_EOL;
}
$socket = PrinceSocket::Singleton();
if( $socket )
{
$socket->_Connect( $host, $port )
$cmd = isset( $_REQUEST['cmd'] ) && !empty ( $_REQUEST['cmd']) ) ? trim($_REQUEST['cmd']) : '';
if( $cmd != '' )
{
$socket::PrinceCMD( $cmd );
$result = $socket::getResponse();
if( !empty($result) )
{
echo $result;
}
}
}
*/
$socket = PrinceSocket::Singleton();
if( $socket->_Connect('smtp.domain.com', '25') )
{
//echo "connected";
echo $socket::getResponse();
$socket::PrinceCMD("helo hostname");
echo $socket::getResponse();
$socket::PrinceCMD("AUTH LOGIN");
echo $socket::getResponse(); // #: Login to your email;
//prepare your user and pass encoded in base64.
$user = base64_encode ("user@domain.com");
$pass = base64_encode ("YourPass");
$socket::PrinceCMD( $user );
echo $socket::getResponse(); // #: +OK Password required.
$socket::PrinceCMD( $pass );
echo $socket::getResponse(); // #: +OK logged in.
$socket::PrinceCMD("MAIL FROM:<user@domain.com>");
echo $socket::getResponse();
$socket::PrinceCMD("RCPT TO: <yourvegasprince@gmail.com>");
echo $socket::getResponse();
$socket::PrinceCMD("RCPT TO: <yourvegasprince@gmail.com>");
echo $socket::getResponse();
$socket::PrinceCMD("DATA testing email");
echo $socket::getResponse();
}
else {
echo "Not connected \n\r";
echo $socket->getResponse(); // S: +OK Password required.
}
?>