POP3
in package
PHPMailer POP-Before-SMTP Authentication Class.
Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.
- This class does not support APOP authentication.
- Opening and closing lots of POP3 connections can be quite slow. If you need to send a batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine.
- This is really ancient technology; you should only need to use it to talk to very old systems.
- This POP3 class is deliberately lightweight and incomplete, implementing just enough to do authentication. If you want a more complete class there are other POP3 classes for PHP available.
Tags
Table of Contents
Constants
- DEBUG_CLIENT = 2
- Debug level to show client -> server and server -> client messages.
- DEBUG_OFF = 0
- Debug level for no output.
- DEBUG_SERVER = 1
- Debug level to show server -> client messages also shows clients connection errors or errors from server
- DEFAULT_PORT = 110
- Default POP3 port number.
- DEFAULT_TIMEOUT = 30
- Default timeout in seconds.
- LE = "\r\n"
- Line break constant.
- VERSION = '6.9.1'
- The POP3 PHPMailer Version number.
Properties
- $do_debug : int
- POP3 class debug output mode.
- $host : string
- POP3 mail server hostname.
- $password : string
- POP3 password.
- $port : int
- POP3 port number.
- $tval : int
- POP3 Timeout Value in seconds.
- $username : string
- POP3 username.
- $connected : bool
- Are we connected?
- $errors : array<string|int, mixed>
- Error container.
- $pop_conn : resource
- Resource handle for the POP3 connection socket.
Methods
- authorise() : bool
- Authenticate with a POP3 server.
- connect() : bool
- Connect to a POP3 server.
- disconnect() : mixed
- Disconnect from the POP3 server.
- getErrors() : array<string|int, mixed>
- Get an array of error messages, if any.
- login() : bool
- Log in to the POP3 server.
- popBeforeSmtp() : bool
- Simple static wrapper for all-in-one POP before SMTP.
- catchWarning() : mixed
- POP3 connection error handler.
- checkResponse() : bool
- Checks the POP3 server response.
- getResponse() : string
- Get a response from the POP3 server.
- sendString() : int
- Send raw data to the POP3 server.
- setError() : mixed
- Add an error to the internal error store.
Constants
DEBUG_CLIENT
Debug level to show client -> server and server -> client messages.
public
int
DEBUG_CLIENT
= 2
DEBUG_OFF
Debug level for no output.
public
int
DEBUG_OFF
= 0
DEBUG_SERVER
Debug level to show server -> client messages also shows clients connection errors or errors from server
public
int
DEBUG_SERVER
= 1
DEFAULT_PORT
Default POP3 port number.
public
int
DEFAULT_PORT
= 110
DEFAULT_TIMEOUT
Default timeout in seconds.
public
int
DEFAULT_TIMEOUT
= 30
LE
Line break constant.
public
mixed
LE
= "\r\n"
VERSION
The POP3 PHPMailer Version number.
public
string
VERSION
= '6.9.1'
Properties
$do_debug
POP3 class debug output mode.
public
int
$do_debug
= self::DEBUG_OFF
Debug output level. Options:
Tags
$host
POP3 mail server hostname.
public
string
$host
$password
POP3 password.
public
string
$password
$port
POP3 port number.
public
int
$port
$tval
POP3 Timeout Value in seconds.
public
int
$tval
$username
POP3 username.
public
string
$username
$connected
Are we connected?
protected
bool
$connected
= false
$errors
Error container.
protected
array<string|int, mixed>
$errors
= []
$pop_conn
Resource handle for the POP3 connection socket.
protected
resource
$pop_conn
Methods
authorise()
Authenticate with a POP3 server.
public
authorise(string $host[, int|bool $port = false ][, int|bool $timeout = false ][, string $username = '' ][, string $password = '' ][, int $debug_level = 0 ]) : bool
A connect, login, disconnect sequence appropriate for POP-before SMTP authorisation.
Parameters
- $host : string
-
The hostname to connect to
- $port : int|bool = false
-
The port number to connect to
- $timeout : int|bool = false
-
The timeout value
- $username : string = ''
- $password : string = ''
- $debug_level : int = 0
Return values
boolconnect()
Connect to a POP3 server.
public
connect(string $host[, int|bool $port = false ][, int $tval = 30 ]) : bool
Parameters
- $host : string
- $port : int|bool = false
- $tval : int = 30
Return values
booldisconnect()
Disconnect from the POP3 server.
public
disconnect() : mixed
getErrors()
Get an array of error messages, if any.
public
getErrors() : array<string|int, mixed>
Return values
array<string|int, mixed>login()
Log in to the POP3 server.
public
login([string $username = '' ][, string $password = '' ]) : bool
Does not support APOP (RFC 2828, 4949).
Parameters
- $username : string = ''
- $password : string = ''
Return values
boolpopBeforeSmtp()
Simple static wrapper for all-in-one POP before SMTP.
public
static popBeforeSmtp(string $host[, int|bool $port = false ][, int|bool $timeout = false ][, string $username = '' ][, string $password = '' ][, int $debug_level = 0 ]) : bool
Parameters
- $host : string
-
The hostname to connect to
- $port : int|bool = false
-
The port number to connect to
- $timeout : int|bool = false
-
The timeout value
- $username : string = ''
- $password : string = ''
- $debug_level : int = 0
Return values
boolcatchWarning()
POP3 connection error handler.
protected
catchWarning(int $errno, string $errstr, string $errfile, int $errline) : mixed
Parameters
- $errno : int
- $errstr : string
- $errfile : string
- $errline : int
checkResponse()
Checks the POP3 server response.
protected
checkResponse(string $string) : bool
Looks for for +OK or -ERR.
Parameters
- $string : string
Return values
boolgetResponse()
Get a response from the POP3 server.
protected
getResponse([int $size = 128 ]) : string
Parameters
- $size : int = 128
-
The maximum number of bytes to retrieve
Return values
stringsendString()
Send raw data to the POP3 server.
protected
sendString(string $string) : int
Parameters
- $string : string
Return values
intsetError()
Add an error to the internal error store.
protected
setError(string $error) : mixed
Also display debug output if it's enabled.
Parameters
- $error : string