本文整理汇总了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;
}
示例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);
示例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);
}