1 | <?php |
||
41 | class POP3 |
||
42 | { |
||
43 | /** |
||
44 | * The POP3 PHPMailer Version number. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | const VERSION = '6.0.1'; |
||
49 | |||
50 | /** |
||
51 | * Default POP3 port number. |
||
52 | * |
||
53 | * @var int |
||
54 | */ |
||
55 | const DEFAULT_PORT = 110; |
||
56 | |||
57 | /** |
||
58 | * Default timeout in seconds. |
||
59 | * |
||
60 | * @var int |
||
61 | */ |
||
62 | const DEFAULT_TIMEOUT = 30; |
||
63 | |||
64 | /** |
||
65 | * Debug display level. |
||
66 | * Options: 0 = no, 1+ = yes. |
||
67 | * |
||
68 | * @var int |
||
69 | */ |
||
70 | public $do_debug = 0; |
||
71 | |||
72 | /** |
||
73 | * POP3 mail server hostname. |
||
74 | * |
||
75 | * @var string |
||
76 | */ |
||
77 | public $host; |
||
78 | |||
79 | /** |
||
80 | * POP3 port number. |
||
81 | * |
||
82 | * @var int |
||
83 | */ |
||
84 | public $port; |
||
85 | |||
86 | /** |
||
87 | * POP3 Timeout Value in seconds. |
||
88 | * |
||
89 | * @var int |
||
90 | */ |
||
91 | public $tval; |
||
92 | |||
93 | /** |
||
94 | * POP3 username. |
||
95 | * |
||
96 | * @var string |
||
97 | */ |
||
98 | public $username; |
||
99 | |||
100 | /** |
||
101 | * POP3 password. |
||
102 | * |
||
103 | * @var string |
||
104 | */ |
||
105 | public $password; |
||
106 | |||
107 | /** |
||
108 | * Resource handle for the POP3 connection socket. |
||
109 | * |
||
110 | * @var resource |
||
111 | */ |
||
112 | protected $pop_conn; |
||
113 | |||
114 | /** |
||
115 | * Are we connected? |
||
116 | * |
||
117 | * @var bool |
||
118 | */ |
||
119 | protected $connected = false; |
||
120 | |||
121 | /** |
||
122 | * Error container. |
||
123 | * |
||
124 | * @var array |
||
125 | */ |
||
126 | protected $errors = []; |
||
127 | |||
128 | /** |
||
129 | * Line break constant. |
||
130 | */ |
||
131 | const LE = "\r\n"; |
||
132 | |||
133 | /** |
||
134 | * Simple static wrapper for all-in-one POP before SMTP. |
||
135 | * |
||
136 | * @param string $host The hostname to connect to |
||
137 | * @param int|bool $port The port number to connect to |
||
138 | * @param int|bool $timeout The timeout value |
||
139 | * @param string $username |
||
140 | * @param string $password |
||
141 | * @param int $debug_level |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | public static function popBeforeSmtp( |
||
157 | |||
158 | /** |
||
159 | * Authenticate with a POP3 server. |
||
160 | * A connect, login, disconnect sequence |
||
161 | * appropriate for POP-before SMTP authorisation. |
||
162 | * |
||
163 | * @param string $host The hostname to connect to |
||
164 | * @param int|bool $port The port number to connect to |
||
165 | * @param int|bool $timeout The timeout value |
||
166 | * @param string $username |
||
167 | * @param string $password |
||
168 | * @param int $debug_level |
||
169 | * |
||
170 | * @return bool |
||
171 | */ |
||
172 | public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0) |
||
207 | |||
208 | /** |
||
209 | * Connect to a POP3 server. |
||
210 | * |
||
211 | * @param string $host |
||
212 | * @param int|bool $port |
||
213 | * @param int $tval |
||
214 | * |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function connect($host, $port = false, $tval = 30) |
||
268 | |||
269 | /** |
||
270 | * Log in to the POP3 server. |
||
271 | * Does not support APOP (RFC 2828, 4949). |
||
272 | * |
||
273 | * @param string $username |
||
274 | * @param string $password |
||
275 | * |
||
276 | * @return bool |
||
277 | */ |
||
278 | public function login($username = '', $password = '') |
||
304 | |||
305 | /** |
||
306 | * Disconnect from the POP3 server. |
||
307 | */ |
||
308 | public function disconnect() |
||
319 | |||
320 | /** |
||
321 | * Get a response from the POP3 server. |
||
322 | * |
||
323 | * @param int $size The maximum number of bytes to retrieve |
||
324 | * |
||
325 | * @return string |
||
326 | */ |
||
327 | protected function getResponse($size = 128) |
||
336 | |||
337 | /** |
||
338 | * Send raw data to the POP3 server. |
||
339 | * |
||
340 | * @param string $string |
||
341 | * |
||
342 | * @return int |
||
343 | */ |
||
344 | protected function sendString($string) |
||
356 | |||
357 | /** |
||
358 | * Checks the POP3 server response. |
||
359 | * Looks for for +OK or -ERR. |
||
360 | * |
||
361 | * @param string $string |
||
362 | * |
||
363 | * @return bool |
||
364 | */ |
||
365 | protected function checkResponse($string) |
||
375 | |||
376 | /** |
||
377 | * Add an error to the internal error store. |
||
378 | * Also display debug output if it's enabled. |
||
379 | * |
||
380 | * @param string $error |
||
381 | */ |
||
382 | protected function setError($error) |
||
393 | |||
394 | /** |
||
395 | * Get an array of error messages, if any. |
||
396 | * |
||
397 | * @return array |
||
398 | */ |
||
399 | public function getErrors() |
||
403 | |||
404 | /** |
||
405 | * POP3 connection error handler. |
||
406 | * |
||
407 | * @param int $errno |
||
408 | * @param string $errstr |
||
409 | * @param string $errfile |
||
410 | * @param int $errline |
||
411 | */ |
||
412 | protected function catchWarning($errno, $errstr, $errfile, $errline) |
||
419 | } |
||
420 |
If you suppress an error, we recommend checking for the error condition explicitly: