当前位置: 首页>>代码示例>>PHP>>正文


PHP SMTP::getLastReply方法代码示例

本文整理汇总了PHP中SMTP::getLastReply方法的典型用法代码示例。如果您正苦于以下问题:PHP SMTP::getLastReply方法的具体用法?PHP SMTP::getLastReply怎么用?PHP SMTP::getLastReply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMTP的用法示例。


在下文中一共展示了SMTP::getLastReply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ping_mail_server

function ping_mail_server($host, $port, $user, $password, $timeout = 5, $secure = 'none')
{
    global $config;
    include_once $config['base_path'] . '/lib/PHPMailer/PHPMailerAutoload.php';
    //Create a new SMTP instance
    $smtp = new SMTP();
    if ($secure != 'tls' && $secure != 'none') {
        $smtp->SMTPSecure = $secure;
        if (substr_count($host, ':') == 0) {
            $host = $secure . '://' . $host;
        }
    }
    //Enable connection-level debug output
    $smtp->do_debug = 0;
    //$smtp->do_debug = SMTP::DEBUG_LOWLEVEL;
    $results = true;
    try {
        //Connect to an SMTP server
        if ($smtp->connect($host, $port, $timeout)) {
            //Say hello
            if ($smtp->hello(gethostbyname(gethostname()))) {
                //Put your host name in here
                //Authenticate
                if ($smtp->authenticate($user, $password)) {
                    $results = true;
                } else {
                    throw new Exception('Authentication failed: ' . $smtp->getLastReply());
                }
            } else {
                throw new Exception('HELO failed: ' . $smtp->getLastReply());
            }
        } else {
            throw new Exception('Connect failed');
        }
    } catch (Exception $e) {
        $results = 'SMTP error: ' . $e->getMessage();
    }
    //Whatever happened, close the connection.
    $smtp->quit(true);
    return $results;
}
开发者ID:MrWnn,项目名称:cacti,代码行数:41,代码来源:functions.php

示例2: SMTP

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new SMTP instance
$smtp = new SMTP();
//Enable connection-level debug output
$smtp->do_debug = SMTP::DEBUG_CONNECTION;
try {
    //Connect to an SMTP server
    if ($smtp->connect('lima.pegasushosting.nl', 995)) {
        //Say hello
        if ($smtp->hello('localhost')) {
            //Put your host name in here
            //Authenticate
            if ($smtp->authenticate('username', 'password')) {
                echo "Connected ok!";
            } else {
                throw new Exception('Authentication failed: ' . $smtp->getLastReply());
            }
        } else {
            throw new Exception('HELO failed: ' . $smtp->getLastReply());
        }
    } else {
        throw new Exception('Connect failed');
    }
} catch (Exception $e) {
    echo 'SMTP error: ' . $e->getMessage(), "\n";
}
//Whatever happened, close the connection.
$smtp->quit(true);
开发者ID:heinbakker,项目名称:KBS-examenanalyse,代码行数:31,代码来源:smtp_check.php

示例3: checkSmtp

 public function checkSmtp()
 {
     //Create a new SMTP instance
     $smtp = new \SMTP();
     //Enable connection-level debug output
     $smtp->do_debug = \SMTP::DEBUG_CONNECTION;
     try {
         //Connect to an SMTP server
         if ($smtp->connect($this->getSmtpServer()->getSmtpHost(), $this->getSmtpServer()->getSmtpPort())) {
             //Say hello
             if ($smtp->hello($this->smtp->getSmtpHost())) {
                 //Put your host name in here
                 //Authenticate
                 dump($this->getSmtpServer()->getSmtpUsername());
                 dump($this->getSmtpServer()->getSmtpPassword());
                 if ($smtp->authenticate($this->getSmtpServer()->getSmtpUsername(), $this->getSmtpServer()->getSmtpPassword())) {
                     return true;
                 } else {
                     throw new \Exception('Authentication failed: ' . $smtp->getLastReply());
                 }
             } else {
                 throw new \Exception('HELO failed: ' . $smtp->getLastReply());
             }
         } else {
             throw new \Exception('Connect failed');
         }
     } catch (\Exception $e) {
         throw new \Exception('SMTP error: ' . $e->getMessage());
     }
     //Whatever happened, close the connection.
     $smtp->quit(true);
 }
开发者ID:diego3,项目名称:myframework-core,代码行数:32,代码来源:PhpMailer.php


注:本文中的SMTP::getLastReply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。