PHP Class PHPMailer\PHPMailer\POP3

Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication. 1) This class does not support APOP authentication. 2) 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. 3) This is really ancient technology; you should only need to use it to talk to very old systems. 4) This POP3 class is deliberately lightweight and incomplete, and implements just enough to do authentication. If you want a more complete class there are other POP3 classes for PHP available.
Author: Richard Davey (original author) ([email protected])
Author: Marcus Bointon (Synchro/coolbru) ([email protected])
Author: Jim Jagielski (jimjag) ([email protected])
Author: Andy Prevost (codeworxtech) ([email protected])
Show file Open project: nukeviet/nukeviet

Public Properties

Property Type Description
$POP3_PORT integer Default POP3 port number.
$POP3_TIMEOUT integer Default timeout in seconds.
$Version string The POP3 PHPMailer Version number.
$do_debug integer Options: 0 = no, 1+ = yes
$host string POP3 mail server hostname.
$password string POP3 password.
$port integer POP3 port number.
$tval integer POP3 Timeout Value in seconds.
$username string POP3 username

Protected Properties

Property Type Description
$connected boolean Are we connected?
$errors array Error container.
$pop_conn resource Resource handle for the POP3 connection socket.

Public Methods

Method Description
authorise ( string $host, integer | boolean $port = false, integer | boolean $timeout = false, string $username = '', string $password = '', integer $debug_level ) : boolean Authenticate with a POP3 server.
connect ( string $host, integer | boolean $port = false, integer $tval = 30 ) : boolean Connect to a POP3 server.
disconnect ( ) Disconnect from the POP3 server.
getErrors ( ) : array Get an array of error messages, if any.
login ( string $username = '', string $password = '' ) : boolean Log in to the POP3 server.
popBeforeSmtp ( $host, integer | boolean $port = false, integer | boolean $timeout = false, string $username = '', string $password = '', integer $debug_level ) : boolean Simple static wrapper for all-in-one POP before SMTP

Protected Methods

Method Description
catchWarning ( integer $errno, string $errstr, string $errfile, integer $errline ) POP3 connection error handler.
checkResponse ( string $string ) : boolean Checks the POP3 server response.
getResponse ( integer $size = 128 ) : string Get a response from the POP3 server.
sendString ( string $string ) : integer Send raw data to the POP3 server.
setError ( $error ) Add an error to the internal error store.

Method Details

authorise() public method

A connect, login, disconnect sequence appropriate for POP-before SMTP authorisation.
public authorise ( string $host, integer | boolean $port = false, integer | boolean $timeout = false, string $username = '', string $password = '', integer $debug_level ) : boolean
$host string The hostname to connect to
$port integer | boolean The port number to connect to
$timeout integer | boolean The timeout value
$username string
$password string
$debug_level integer
return boolean

catchWarning() protected method

POP3 connection error handler.
protected catchWarning ( integer $errno, string $errstr, string $errfile, integer $errline )
$errno integer
$errstr string
$errfile string
$errline integer

checkResponse() protected method

Looks for for +OK or -ERR.
protected checkResponse ( string $string ) : boolean
$string string
return boolean

connect() public method

Connect to a POP3 server.
public connect ( string $host, integer | boolean $port = false, integer $tval = 30 ) : boolean
$host string
$port integer | boolean
$tval integer
return boolean

disconnect() public method

Disconnect from the POP3 server.
public disconnect ( )

getErrors() public method

Get an array of error messages, if any.
public getErrors ( ) : array
return array

getResponse() protected method

$size is the maximum number of bytes to retrieve
protected getResponse ( integer $size = 128 ) : string
$size integer
return string

login() public method

Does not support APOP (RFC 2828, 4949).
public login ( string $username = '', string $password = '' ) : boolean
$username string
$password string
return boolean

popBeforeSmtp() public static method

Simple static wrapper for all-in-one POP before SMTP
public static popBeforeSmtp ( $host, integer | boolean $port = false, integer | boolean $timeout = false, string $username = '', string $password = '', integer $debug_level ) : boolean
$host
$port integer | boolean The port number to connect to
$timeout integer | boolean The timeout value
$username string
$password string
$debug_level integer
return boolean

sendString() protected method

Send raw data to the POP3 server.
protected sendString ( string $string ) : integer
$string string
return integer

setError() protected method

Also display debug output if it's enabled.
protected setError ( $error )
$error

Property Details

$POP3_PORT public property

Default POP3 port number.
public int $POP3_PORT
return integer

$POP3_TIMEOUT public property

Default timeout in seconds.
public int $POP3_TIMEOUT
return integer

$Version public property

The POP3 PHPMailer Version number.
public string $Version
return string

$connected protected property

Are we connected?
protected bool $connected
return boolean

$do_debug public property

Options: 0 = no, 1+ = yes
public int $do_debug
return integer

$errors protected property

Error container.
protected array $errors
return array

$host public property

POP3 mail server hostname.
public string $host
return string

$password public property

POP3 password.
public string $password
return string

$pop_conn protected property

Resource handle for the POP3 connection socket.
protected resource $pop_conn
return resource

$port public property

POP3 port number.
public int $port
return integer

$tval public property

POP3 Timeout Value in seconds.
public int $tval
return integer

$username public property

POP3 username
public string $username
return string