本文整理汇总了PHP中SMTP::send方法的典型用法代码示例。如果您正苦于以下问题:PHP SMTP::send方法的具体用法?PHP SMTP::send怎么用?PHP SMTP::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMTP
的用法示例。
在下文中一共展示了SMTP::send方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_mail
function send_mail($name, $email, $ip, $is_spam, $message)
{
$subject = '';
if ($is_spam == false && empty($name) == false && empty($email) == false) {
$subject = $GLOBALS['CONTACT_SUBJECT'];
$smtp = new SMTP($GLOBALS['SMTP_SERVER'], $GLOBALS['SMTP_PORT']);
$smtp->mail_from($email);
return $smtp->send($GLOBALS['CONTACT_RECIPIENT'], $subject, "Name: " . $name . "\n\n" . stripslashes($message));
} else {
return true;
}
}
示例2: mail
/**
* 快捷发送一封邮件
* @param string $to 收件人
* @param string $sub 邮件主题
* @param string $msg 邮件内容(HTML)
* @param array $att 附件,每个键为文件名称,值为附件内容(可以为二进制文件),例如array('a.txt' => 'abcd' , 'b.png' => file_get_contents('x.png'))
* @return bool 成功:true 失败:错误消息
*/
public static function mail($to, $sub = '无主题', $msg = '无内容', $att = array())
{
if (defined("SAE_MYSQL_DB") && class_exists('SaeMail')) {
$mail = new SaeMail();
$options = array('from' => option::get('mail_name'), 'to' => $to, 'smtp_host' => option::get('mail_host'), 'smtp_port' => option::get('mail_port'), 'smtp_username' => option::get('mail_smtpname'), 'smtp_password' => option::get('mail_smtppw'), 'subject' => $sub, 'content' => $msg, 'content_type' => 'HTML');
$mail->setOpt($options);
$ret = $mail->send();
if ($ret === false) {
return 'Mail Send Error: #' . $mail->errno() . ' - ' . $mail->errmsg();
} else {
return true;
}
} else {
$From = option::get('mail_name');
if (option::get('mail_mode') == 'SMTP') {
$Host = option::get('mail_host');
$Port = intval(option::get('mail_port'));
$SMTPAuth = (bool) option::get('mail_auth');
$Username = option::get('mail_smtpname');
$Password = option::get('mail_smtppw');
$Nickname = option::get('mail_yourname');
if (option::get('mail_ssl') == '1') {
$SSL = true;
} else {
$SSL = false;
}
$mail = new SMTP($Host, $Port, $SMTPAuth, $Username, $Password, $SSL);
$mail->att = $att;
if ($mail->send($to, $From, $sub, $msg, $Nickname)) {
return true;
} else {
return $mail->log;
}
} else {
$name = option::get('mail_yourname');
$mail = new PHPMailer();
$mail->setFrom($From, $name);
$mail->addAddress($to);
$mail->Subject = $sub;
$mail->msgHTML($msg);
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
foreach ($att as $n => $d) {
$mail->addStringAttachment($d, "=?UTF-8?B?" . base64_encode($n) . "?=", 'base64', get_mime(get_extname($n)));
}
if (!$mail->send()) {
return $mail->ErrorInfo;
} else {
return true;
}
}
}
}
示例3: sendmail
/**
* adapter for SMTP
*
* @param string $subject
* @param string $content
* @param email $receiver
*
* @return string done or error message
*/
static function sendmail($subject, $content, $receiver)
{
$to_address = $receiver == "" ? f3()->get('inquiry_receiver') : $receiver;
$smtp = new \SMTP(f3()->get('smtp_host'), f3()->get('smtp_port'), 'SSL', f3()->get('smtp_account'), f3()->get('smtp_password'));
$smtp->set('From', '"' . f3()->get('smtp_name') . '" <' . f3()->get('smtp_account') . '>');
$smtp->set('To', '<' . $to_address . '>');
$smtp->set('Subject', $subject);
$smtp->set('Errors-to', '<' . f3()->get('smtp_account') . '>');
$smtp->set('Content-Type', 'text/html');
$sent = $smtp->send($content, TRUE);
$mylog = $smtp->log();
if ($sent) {
return 'Done';
} else {
return $mylog;
}
}
示例4: mail
/**
* 快捷发送一封邮件
* @param string $to 收件人
* @param string $sub 邮件主题
* @param string $msg 邮件内容(HTML)
* @param array $att 附件,每个键为文件名称,值为附件内容(可以为二进制文件),例如array('a.txt' => 'abcd' , 'b.png' => file_get_contents('x.png'))
* @return bool 成功:true 失败:错误消息
*/
public static function mail($to, $sub = '无主题', $msg = '无内容', $att = array())
{
if (defined("SAE_MYSQL_DB") && class_exists('SaeMail')) {
$mail = new SaeMail();
$options = array('from' => option::get('mail_name'), 'to' => $to, 'smtp_host' => option::get('mail_host'), 'smtp_port' => option::get('mail_port'), 'smtp_username' => option::get('mail_smtpname'), 'smtp_password' => option::get('mail_smtppw'), 'subject' => $sub, 'content' => $msg, 'content_type' => 'HTML');
$mail->setOpt($options);
$ret = $mail->send();
if ($ret === false) {
return 'Mail Send Error: #' . $mail->errno() . ' - ' . $mail->errmsg();
} else {
return true;
}
} else {
$From = option::get('mail_name');
if (option::get('mail_mode') == 'SMTP') {
$Host = option::get('mail_host');
$Port = intval(option::get('mail_port'));
$SMTPAuth = (bool) option::get('mail_auth');
$Username = option::get('mail_smtpname');
$Password = option::get('mail_smtppw');
$Nickname = option::get('mail_yourname');
if (option::get('mail_ssl') == '1') {
$SSL = true;
} else {
$SSL = false;
}
$mail = new SMTP($Host, $Port, $SMTPAuth, $Username, $Password, $SSL);
$mail->att = $att;
if ($mail->send($to, $From, $sub, $msg, $Nickname)) {
return true;
} else {
return $mail->log;
}
} else {
$header = "MIME-Version:1.0\r\n";
$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$header .= "To: " . $to . "\r\n";
$header .= "From: " . $From . "\r\n";
$header .= "Subject: " . $sub . "\r\n";
$header .= 'Reply-To: ' . $From . "\r\n";
$header .= "Date: " . date("r") . "\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
return mail($to, $sub, base64_encode($msg), $header);
}
}
}
示例5: explode
$to = 'client@destination.net';
// 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);
示例6: send_mail
function send_mail($to, $sub, $msg)
{
global $conf, $mail_api;
if ($mail_api != 0) {
global $mail_api_url;
$post[sendto] = $to;
$post[title] = $sub;
$post[content] = $msg;
$post[user] = $conf['mail_name'];
$post[pwd] = $conf['mail_pwd'];
$post[nick] = $conf['sitename'];
$post[host] = $conf['mail_stmp'];
$post[port] = $conf['mail_port'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $mail_api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);
if ($ret == '1') {
return true;
} else {
return $ret;
}
} else {
include_once ROOT . 'includes/smtp.class.php';
$From = $conf['mail_name'];
$Host = $conf['mail_stmp'];
$Port = $conf['mail_port'];
$SMTPAuth = 1;
$Username = $conf['mail_name'];
$Password = $conf['mail_pwd'];
$Nickname = $conf['sitename'];
$SSL = false;
$mail = new SMTP($Host, $Port, $SMTPAuth, $Username, $Password, $SSL);
$mail->att = array();
if ($mail->send($to, $From, $sub, $msg, $Nickname)) {
return true;
} else {
return $mail->log;
}
}
}
示例7: relay
/* Purpose:
- 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);
示例8: date
$user = new DB\SQL\Mapper($db, 'memos');
$user->load(array('email = :username LIMIT 0,1', ':username' => $username));
if ($user->dry()) {
$user->role = 'subscriber';
$user->created = date('Y-m-d H:i:s');
// Send email to Admin with the good news: a new user!
$smtp = new SMTP(SMTP_SERVER, SMTP_PORT, SMTP_PROTOCOL, SMTP_USERNAME, SMTP_PASSWORD);
$smtp->set('From', '"Do Not Forget Me" <' . ADMIN_EMAIL . '>');
$smtp->set('To', '<' . ADMIN_EMAIL . '>');
$smtp->set('Subject', 'Yay, New DNFM User : ' . $user_profile->displayName);
$smtp->set('Errors-to', '<' . ADMIN_EMAIL . '>');
$message = "On " . date('Y-m-d at H:i') . ", a new user subscribed to Do Not Forget Me!";
$message .= "\n\nname: " . $user_profile->displayName;
$message .= "\nemail: " . $user_profile->email;
$message .= "\n\n\nPop up the champaign!";
$sent = $smtp->send($message, TRUE);
$mylog = $smtp->log();
}
$user->email = $username;
if (!empty($user_profile->displayName)) {
$user->name = $user_profile->displayName;
}
if (!empty($user_profile->firstName)) {
$user->first = $user_profile->firstName;
}
if (!empty($user_profile->photoURL)) {
$user->image = $user_profile->photoURL;
}
$user->save();
$f3->set('SESSION.name', $user->name);
$f3->set('SESSION.id', $user->id);
示例9: 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);
}
示例10: count
$content .= '<tr>';
$content .= '<td style="width: 120px;">Адрес:</td>';
$content .= '<td colspan="4" style="font-weight: bold;">' . $item['address'] . '</td>';
$content .= '</tr>';
if ($item['goods']) {
$content .= '<tr>';
$content .= '<td rowspan="' . count($item['goods']) . '" style="width: 120px; vertical-align: top;">Товары:</td>';
foreach ($item['goods'] as $key => $value) {
$content .= '<td style="width: 20px; text-align: center;">' . ($key + 1) . '.</td>';
$content .= '<td style="font-size: 11px;">' . $value['name'] . '</td>';
$content .= '<td style="width: 80px; text-align: center;">' . $value['count'] . ' шт.</td>';
$content .= '<td style="width: 120px; text-align: center;">' . number_format($value['count'] * $value['price'], 2, '.', ' ') . ' руб.</td>';
$content .= '</tr>';
}
}
$content .= '</table><br />';
}
} else {
// Вывод письма без заказов;
$content .= 'Нет заказов';
}
// Отправка почты;
$smtp->send($partner['email'], 'ExtremeFitness', $content);
$smtp->send('verchenko@yandex.ru', 'ExtremeFitness (' . $partner['name'] . ')', $content);
$smtp->send('sid.art@inbox.ru', 'ExtremeFitness (' . $partner['name'] . ')', $content);
$smtp->send('olga.dmitrieva@ngs.ru', 'ExtremeFitness (' . $partner['name'] . ')', $content);
//echo $content.'<br />';
// Логирование;
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/files/logs/goods_email/' . date("Ymd") . '.log', date("d.m.Y, H:i:s") . ' - ' . $partner['name'] . ', ' . $partner['email'] . "\r\n" . $content . "\r\n\r\n", FILE_APPEND);
}
}