-
Notifications
You must be signed in to change notification settings - Fork 6
/
SMTP.php
130 lines (105 loc) · 3.65 KB
/
SMTP.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* SMTP
*
* @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
*/
/**
* Report only critical errors. Set this to E_ALL to report all PHP errors
*/
error_reporting(E_ERROR);
/**
* Unlimited execution time to accomodate the infinite run() loop
*/
set_time_limit(0);
/**
* IP address and port to use. Set SMTP_HOST to the public-facing IP address you want
* the SMTP server to listen on.
*/
define('SMTP_HOST', '127.0.0.1');
define('SMTP_PORT', 25);
/**
* A comma separated list of domains, e.g. "example1.com,example2.com" When set to this,
* the server will accept email for accounts *@example1.com and *@example2.com.
*/
define('SMTP_VALID_DOMAINS', '');
/**
* Messages and storage
*/
define('SMTP_INBOUND', './inbound/');
define('SMTP_OUTBOUND', './outbound/');
// Default max message size of 2MB
define('SMTP_MAX_SIZE', 2097152);
// Read from sockets in 1K chunks
define('SMTP_CHUNK_SIZE', 1024);
/**
* SMTP response codes
*/
// 200's
define('SMTP_211', '211 System status, or system help reply');
define('SMTP_214', '214 Help message');
define('SMTP_220', '220 Service ready');
define('SMTP_221', '221 Service closing transmission channel');
define('SMTP_235', '235 Authentication successful');
define('SMTP_250', '250 Requested mail action okay, completed');
define('SMTP_251', '251 User not local');
// 300's
define('SMTP_354', '354 Start mail input; end with <CRLF>.<CRLF>');
// 400's
define('SMTP_421', '421 Service not available');
define('SMTP_450', '450 Requested mail action not taken: mailbox unavailable');
define('SMTP_451', '451 Requested action aborted: error in processing');
define('SMTP_452', '452 Requested action not taken: insufficient system storage');
// 500's
define('SMTP_500', '500 Syntax error, command unrecognized');
define('SMTP_501', '501 Syntax error in parameters or arguments');
define('SMTP_502', '502 Command not implemented');
define('SMTP_503', '503 Bad sequence of commands');
define('SMTP_504', '504 Command parameter not implemented');
define('SMTP_535', '535 Authentication failed');
define('SMTP_550', '550 Requested action not taken: mailbox unavailable');
define('SMTP_551', '551 User not local');
define('SMTP_552', '552 Requested mail action aborted: exceeded storage allocation');
define('SMTP_553', '553 Requested action not taken: mailbox name not allowed');
define('SMTP_554', '554 Transaction failed');
/**
* Logging
*/
define('SMTP_LOG', './log/smtp.log');
define('SMTP_CRITICAL', 1);
define('SMTP_ERROR', 2);
define('SMTP_WARNING', 3);
define('SMTP_NOTICE', 4);
define('SMTP_DEBUG', 5);
// Log level, set to SMTP_DEBUG to report all server-server and client-server communication
define('SMTP_LOG_LEVEL', SMTP_DEBUG);
/**
* Indexing
*/
define('SMTP_INDEX', './index');
/**
* API - an "Event" notifies registered methods of something happening, whereas a "Hook"
* directly changes how something works.
*
* Methods receiving events will be passed documented values and should not return anything
* Methods receiving hook challenges will be passed documentd values and should return either true or false
*/
// Events
define('SMTP_API_AUTH_CHALLENGE', 1);
define('SMTP_API_AUTH_SUCCESS', 2);
define('SMTP_API_AUTH_FAILURE', 3);
// Hooks
define('SMTP_API_AUTH', 1);
require_once 'SMTP_Server_API.php';
require_once 'SMTP_Server_Log.php';
require_once 'SMTP_Server_Index.php';
require_once 'SMTP_Server_Socket.php';
require_once 'SMTP_Server_Session.php';
require_once 'SMTP_Server_Relay_Session.php';
require_once 'SMTP_Server_Relay.php';
require_once 'SMTP_Server.php';
?>