POP3::Authorise PHP Method

Authorise() public method

Combination of public events - connect, login, disconnect
public Authorise ( string $host, integer $port = false, integer $tval = false, string $username, string $password, $debug_level )
$host string
$port integer
$tval integer
$username string
$password string
    public function Authorise($host, $port = false, $tval = false, $username, $password, $debug_level = 0)
    {
        $this->host = $host;
        //  If no port value is passed, retrieve it
        if ($port == false) {
            $this->port = $this->POP3_PORT;
        } else {
            $this->port = $port;
        }
        //  If no port value is passed, retrieve it
        if ($tval == false) {
            $this->tval = $this->POP3_TIMEOUT;
        } else {
            $this->tval = $tval;
        }
        $this->do_debug = $debug_level;
        $this->username = $username;
        $this->password = $password;
        //  Refresh the error log
        $this->error = null;
        //  Connect
        $result = $this->Connect($this->host, $this->port, $this->tval);
        if ($result) {
            $login_result = $this->Login($this->username, $this->password);
            if ($login_result) {
                $this->Disconnect();
                return true;
            }
        }
        //  We need to disconnect regardless if the login succeeded
        $this->Disconnect();
        return false;
    }

Usage Example

示例#1
0
function zenphoto_PHPMailer($msg, $email_list, $subject, $message, $from_mail, $from_name, $cc_addresses, $replyTo, $html = false)
{
    require_once dirname(__FILE__) . '/PHPMailer/class.phpmailer.php';
    switch (getOption('PHPMailer_mail_protocol')) {
        case 'pop3':
            require_once dirname(__FILE__) . '/PHPMailer/class.pop3.php';
            $pop = new POP3();
            $authorized = $pop->Authorise(getOption('PHPMailer_server'), getOption('PHPMailer_pop_port'), 30, getOption('PHPMailer_user'), getOption('PHPMailer_password'), 0);
            $mail = new PHPMailer();
            $mail->IsSMTP();
            $mail->Port = getOption('PHPMailer_smtp_port');
            $mail->Host = getOption('PHPMailer_server');
            break;
        case 'smtp':
            $mail = new PHPMailer();
            $mail->SMTPAuth = true;
            // enable SMTP authentication
            $mail->IsSMTP();
            $mail->Username = getOption('PHPMailer_user');
            $mail->Password = getOption('PHPMailer_password');
            $mail->Host = getOption('PHPMailer_server');
            $mail->Port = getOption('PHPMailer_smtp_port');
            break;
        case 'sendmail':
            $mail = new PHPMailer();
            $mail->IsSendmail();
            break;
    }
    $mail->SMTPSecure = getOption('PHPMailer_secure');
    $mail->CharSet = 'UTF-8';
    $mail->From = $from_mail;
    $mail->FromName = $from_name;
    $mail->Subject = $subject;
    $mail->Body = $message;
    $mail->AltBody = '';
    $mail->IsHTML($html);
    foreach ($email_list as $to_name => $to_mail) {
        if (is_numeric($to_name)) {
            $mail->AddAddress($to_mail);
        } else {
            $mail->AddAddress($to_mail, $to_name);
        }
    }
    if (count($cc_addresses) > 0) {
        foreach ($cc_addresses as $cc_name => $cc_mail) {
            $mail->AddCC($cc_mail);
        }
    }
    if ($replyTo) {
        $names = array_keys($replyTo);
        $mail->AddReplyTo(array_shift($replyTo), array_shift($names));
    }
    if (!$mail->Send()) {
        if (!empty($msg)) {
            $msg .= '<br />';
        }
        $msg .= sprintf(gettext('<code>PHPMailer</code> failed to send <em>%1$s</em>. ErrorInfo:%2$s'), $subject, $mail->ErrorInfo);
    }
    return $msg;
}
All Usage Examples Of POP3::Authorise