-
Notifications
You must be signed in to change notification settings - Fork 6
/
SMTP_Server.php
55 lines (46 loc) · 1.18 KB
/
SMTP_Server.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
<?php
/**
* SMTP_Server
*
* @author Jason Johnson <jason@php-smtp.org>
* @copyright Copyright (c) 2008, Jason Johnson
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @version 1.0
* @package php-smtp
*/
class SMTP_Server {
var $socket;
var $host;
var $port;
var $api;
/**
* Constructor, no required parameters if binding to the localhost interface.
*
* @param string $host IP address to bind the server to, defaults to 127.0.0.1
* @param int $port Port to user on the specified host address, defaults to 25
*/
function SMTP_Server($host = null, $port = null) {
global $api;
$this->host = $host?$host:SMTP_HOST;
$this->port = $port?$port:SMTP_PORT;
$this->domains = array();
$this->api = &$api;
$this->socket = new SMTP_Server_Socket();
$this->socket->bind($this->host, $this->port);
$this->socket->listen();
}
/**
* Enters an infinite loop and listens for new connections from remote hosts.
*/
function run() {
while(true) {
$remote = $this->socket->accept();
$session =& new SMTP_Server_Session($remote);
$session->run();
$session = null;
$remote = null;
}
$this->socket->close();
}
}
?>