176 if (
false ===
$port) {
177 $this->port = static::DEFAULT_PORT;
179 $this->port = (int)
$port;
182 if (
false === $timeout) {
183 $this->tval = static::DEFAULT_TIMEOUT;
185 $this->tval = (int) $timeout;
187 $this->do_debug = $debug_level;
195 $login_result = $this->
login($this->username, $this->password);
220 if ($this->connected) {
226 set_error_handler([$this,
'catchWarning']);
228 if (
false ===
$port) {
229 $port = static::DEFAULT_PORT;
235 $this->pop_conn = fsockopen(
243 restore_error_handler();
246 if (
false === $this->pop_conn) {
249 "Failed to connect to server $host on port $port. errno: $errno; errstr: $errstr" 256 stream_set_timeout($this->pop_conn,
$tval, 0);
263 $this->connected =
true;
282 if (!$this->connected) {
283 $this->
setError(
'Not connected to POP3 server');
293 $this->
sendString(
"USER $username" . static::LE);
297 $this->
sendString(
"PASS $password" . static::LE);
316 @fclose($this->pop_conn);
332 if ($this->do_debug >= 1) {
348 if ($this->pop_conn) {
349 if ($this->do_debug >= 2) {
350 echo 'Client -> Server: ', $string;
353 return fwrite($this->pop_conn, $string, strlen($string));
369 if (strpos($string,
'+OK') !== 0) {
370 $this->
setError(
"Server reported an error: $string");
386 $this->errors[] = $error;
387 if ($this->do_debug >= 1) {
389 foreach ($this->errors as $e) {
417 'Connecting to the POP3 server raised a PHP warning:' .
418 "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline" getResponse($size=128)
Get a response from the POP3 server.
connect($host, $port=false, $tval=30)
Connect to a POP3 server.
static popBeforeSmtp( $host, $port=false, $timeout=false, $username='', $password='', $debug_level=0)
Simple static wrapper for all-in-one POP before SMTP.
const LE
Line break constant.
authorise($host, $port=false, $timeout=false, $username='', $password='', $debug_level=0)
Authenticate with a POP3 server.
checkResponse($string)
Checks the POP3 server response.
sendString($string)
Send raw data to the POP3 server.
catchWarning($errno, $errstr, $errfile, $errline)
POP3 connection error handler.
setError($error)
Add an error to the internal error store.
PHPMailer POP-Before-SMTP Authentication Class.
getErrors()
Get an array of error messages, if any.
login($username='', $password='')
Log in to the POP3 server.
disconnect()
Disconnect from the POP3 server.
Get an OAuth2 token from an OAuth2 provider.