本文整理汇总了PHP中SMTP::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP SMTP::disconnect方法的具体用法?PHP SMTP::disconnect怎么用?PHP SMTP::disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMTP
的用法示例。
在下文中一共展示了SMTP::disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relay
- send mail relay (using Gmail MTA) with authentication via SSL conection (TLS encryption)
*/
// manage errors
error_reporting(E_ALL);
// php errors
define('DISPLAY_XPM4_ERRORS', true);
// display XPM4 errors
// path to 'SMTP.php' file from XPM4 package
require_once '../SMTP.php';
$f = 'username@gmail.com';
// from (Gmail mail address)
$t = 'client@destination.net';
// to mail address
$p = 'password';
// Gmail password
// standard mail message RFC2822
$m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: test' . "\r\n" . 'Content-Type: text/plain' . "\r\n\r\n" . 'Text message.';
// connect to MTA server (relay) 'smtp.gmail.com' via SSL (TLS encryption) with authentication using port '465' and timeout '10' secounds
// make sure you have OpenSSL module (extension) enable on your php configuration
$c = SMTP::connect('smtp.gmail.com', 465, $f, $p, 'tls', 10) or die(print_r($_RESULT));
// send mail relay
$s = SMTP::send($c, array($t), $m, $f);
// print result
if ($s) {
echo 'Sent !';
} else {
print_r($_RESULT);
}
// disconnect
SMTP::disconnect($c);
示例2: explode
// to mail address
$subj = 'Hello World!';
// mail subject
$text = 'Text version of message.';
// text/plain version of message
$html = '<b>HTML</b> version of <u>message</u>.';
// text/html version of message
// CONFIGURATION ------------------
// set text/plain version of message
$msg1 = MIME::message($text, 'text/plain');
// set text/html version of message
$msg2 = MIME::message($html, 'text/html');
// compose message in MIME format
$mess = MIME::compose($msg1, $msg2);
// standard mail message RFC2822
$body = 'From: ' . $from . "\r\n" . 'To: ' . $to . "\r\n" . 'Subject: ' . $subj . "\r\n" . $mess['header'] . "\r\n\r\n" . $mess['content'];
// get client hostname
$expl = explode('@', $to);
// connect to SMTP server (direct) from MX hosts list
$conn = SMTP::mxconnect($expl[1]) or die(print_r($_RESULT));
// send mail
$sent = SMTP::send($conn, array($to), $body, $from);
// print result
if ($sent) {
echo 'Sent !';
} else {
print_r($_RESULT);
}
// disconnect from SMTP server
SMTP::disconnect($conn);
示例3: send_mail
function send_mail($mailto, $subject, $content, $sender_name = null, $sender_address = null)
{
// $subject=iconv("UTF-8", "EUC-KR", $subject);
// $content=iconv("UTF-8", "EUC-KR", $content);
if (!$sender_name) {
$settings = new Settings();
$sender_name = $settings->default_mail_sender_name;
//$settings->default_mail_sender_address;
}
//return mailer ($from, $fname, $to, $cc, $bcc, $subject, $content, $file, $type, $charset, $textencode)
$smtp_server = "uwa64-001.cafe24.com";
$smtp_user = "admin";
$smtp_passwd = "ok1234";
$sender_address = "admin@trail.or.kr";
$boundary = "___==MultiPart_" . strtoupper(md5(uniqid(rand()))) . "==___";
$smtp_server = "smtp.gmail.com";
$smtp_user = "binseop@gmail.com";
$smtp_passwd = "ok123456";
$sender_address = "binseop@gmail.com";
$smtp_sock = fsockopen($smtp_server, 25);
/*
fputs($smtp_sock, "HELO $smtp_server\r\n");
fputs($smtp_sock, "VRFY $smtp_user\r\n");
fputs($smtp_sock, "MAIL FROM:$sender_address\r\n");
fputs($smtp_sock, "RCPT TO:$mailto\r\n");
fputs($smtp_sock, "DATA\r\n");
fputs($smtp_sock, "From: $sender_name<$sender_address>\r\n");
fputs($smtp_sock, "To: $mailto\r\n");
fputs($smtp_sock, "X-Mailer: miplus\r\n");
fputs($smtp_sock, "Content-Type: text/html;");
fputs($smtp_sock, "charset=UTF-8\r\n");
fputs($smtp_sock, "MIME-Version: 1.0\r\n");
fputs($smtp_sock, "Subject: $subject\r\n\r\n");
fputs($smtp_sock, $content);
fputs($smtp_sock, "\r\n\r\n.\r\nQUIT\r\n");
*/
//include_once ("../../app/XPM/smtp.php");
require_once "../../app/XPM/SMTP.php";
$f = "auth@myjirisan.org";
$t = $mailto;
$p = "trail1";
$c = $content;
$m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: ' . $subject . "\r\n" . 'Content-Type: text/html' . "\r\n\r\n" . $content;
// connect to MTA server (relay) 'smtp.gmail.com' via SSL (TLS encryption) with authentication using port '465' and timeout '10' secounds
// make sure you have OpenSSL module (extension) enable on your php configuration
$c = SMTP::connect('smtp.gmail.com', 465, $f, $p, 'tls', 10) or die(print_r($_RESULT));
// send mail relay
$s = SMTP::send($c, array($t), $m, $f);
/*
// print result
if ($s) echo 'Sent !';
else print_r($_RESULT);
*/
// disconnect
SMTP::disconnect($c);
}