本文整理汇总了PHP中SMTP类的典型用法代码示例。如果您正苦于以下问题:PHP SMTP类的具体用法?PHP SMTP怎么用?PHP SMTP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMTP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enviarcorreo
function enviarcorreo($datos)
{
//$objResponse = new xajaxResponse();
// Se incluye la librería necesaria para el envio
require_once "fzo.mail.php";
$prioridad = 3;
$mail = new SMTP("localhost", 'alfredo@toyolobaimport.com', 'toyo694');
// Se configuran los parametros necesarios para el envío
$de = "ventas@toyolobaimport.com";
$a = "ventas@toyolobaimport.com";
$asunto = "Toyo Loba Import :: Formulario de Contactanos";
//$cc = $_POST['cc'];
//$bcc = $_POST['bcc'];
$cuerpo = "Nombre: " . $datos['nombre'] . "<br>" . "Empresa: " . $datos['empresa'] . "<br>" . "Telefono: " . $datos['telefono'] . "<br>" . "Mensaje: " . $datos['mensaje'] . "<br><br><br><br><br>" . "Este es un correo automatico enviado desde la página de Toyo Loba Import, c.a.";
$header = $mail->make_header($de, $a, $asunto, $prioridad, $cc, $bcc);
/* Pueden definirse más encabezados. Tener en cuenta la terminación de la linea con (\r\n)
$header .= "Reply-To: ".$_POST['from']." \r\n";
$header .= "Content-Type: text/plain; charset=\"iso-8859-1\" \r\n";
$header .= "Content-Transfer-Encoding: 8bit \r\n";
$header .= "MIME-Version: 1.0 \r\n";
*/
// Se envia el correo y se verifica el error
$error = $mail->smtp_send($de, $a, $header, $cuerpo, $cc, $bcc);
if ($error == "0") {
echo "E-mail enviado correctamente";
} else {
echo $error;
}
//return $objResponse;
}
示例2: foreach
/**
* Return an instance of f3 \SMTP populated with application settings
*
* @param array $data
* @return \SMTP
*/
public static function &getMailer(array $data = []) : \SMTP
{
$f3 = \Base::instance();
$smtp = new \SMTP($f3->get('email.host'), $f3->get('email.port'), $f3->get('email.scheme'), $f3->get('email.user'), $f3->get('email.pass'));
$smtp->set('From', $f3->get('email.from'));
// finally set other values like overrides
foreach ($data as $k => $v) {
$smtp->set($k, $v);
}
return $smtp;
}
示例3: 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;
}
}
示例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 {
$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;
}
}
}
}
示例5: 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);
}
示例6: 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);
}
}
}
示例7: __construct
public function __construct()
{
$host = Controller::getEnvironmentData('SMTP_HOST');
$port = Controller::getEnvironmentData('SMTP_PORT');
$scheme = Controller::getEnvironmentData('SMTP_SCHEME');
$user = Controller::getEnvironmentData('SMTP_USER');
$pw = Controller::getEnvironmentData('SMTP_PASS');
parent::__construct($host, $port, $scheme, $user, $pw);
// error handling
$this->set('Errors-to', '' . Controller::getEnvironmentData('SMTP_ERROR') . '>');
$this->set('MIME-Version', '1.0');
$this->set('Content-Type', 'text/html; charset=ISO-8859-1');
}
示例8: send_mail
function send_mail($to_address, $from, $subj, $messg)
{
$smtp = new SMTP('mail.asahi-net.or.jp');
$msg = new Message();
$to = omitNickNameFromMailAddress($to_address);
$subject = mb_encode_mimeheader($subj, "JIS", "auto");
$message = mb_convert_encoding($messg, "JIS", "auto");
/***** Headers ***/
$headers = "";
$headers .= "From: " . $from . "\r\n";
/*
if ($cc){
$CC = omitNickNameFromMailAddress($cc);
$headers .= "Cc: $CC \r\n";
}
if ($bcc)
$BCC = omitNickNameFromMailAddress($bcc);
*/
$msg->createHeader($subject, $from, $to, $CC, $BCC);
$msg->createContent($message);
$ack = $smtp->sendMessage($msg->header, $msg->getMailBody());
return $ack;
}
示例9: 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;
}
}
示例10: ConfigSave
public function ConfigSave()
{
global $sso_settings;
$info = $this->GetInfo();
$info["email_from"] = $_REQUEST["sso_email_two_factor_email_from"];
$info["email_subject"] = trim($_REQUEST["sso_email_two_factor_email_subject"]);
$info["email_msg"] = $_REQUEST["sso_email_two_factor_email_msg"];
$info["email_msg_text"] = SMTP::ConvertHTMLToText($_REQUEST["sso_email_two_factor_email_msg"]);
$info["window"] = (int) $_REQUEST["sso_email_two_factor_window"];
$info["clock_drift"] = (int) $_REQUEST["sso_email_two_factor_clock_drift"];
if (stripos($info["email_msg"], "@TWOFACTOR@") === false) {
BB_SetPageMessage("error", "The E-mail Two-Factor Authentication 'E-mail Message' field does not contain '@TWOFACTOR@'.");
} else {
if ($info["window"] < 30 || $info["window"] > 300) {
BB_SetPageMessage("error", "The E-mail Two-Factor Authentication 'Window Size' field contains an invalid value.");
} else {
if ($info["clock_drift"] < 0 || $info["clock_drift"] > $info["window"]) {
BB_SetPageMessage("error", "The E-mail Two-Factor Authentication 'Window Size' field contains an invalid value.");
}
}
}
$sso_settings["sso_login"]["modules"]["sso_email_two_factor"] = $info;
}
示例11: smtp_send
/**
* Sends mail via SMTP using PhpSMTP (Author:
* Chris Ryan). Returns bool. Returns false if there is a
* bad MAIL FROM, RCPT, or DATA input.
* @private
* @returns bool
*/
function smtp_send($header, $body)
{
// Include SMTP class code, but not twice
include_once $this->PluginDir . "class.smtp.php";
$smtp = new SMTP();
$smtp->do_debug = $this->SMTPDebug;
// Try to connect to all SMTP servers
$hosts = explode(";", $this->Host);
$index = 0;
$connection = false;
$smtp_from = "";
$bad_rcpt = array();
$e = "";
// Retry while there is no connection
while ($index < count($hosts) && $connection == false) {
if (strstr($hosts[$index], ":")) {
list($host, $port) = explode(":", $hosts[$index]);
} else {
$host = $hosts[$index];
$port = $this->Port;
}
if ($smtp->Connect($host, $port, $this->Timeout)) {
$connection = true;
}
//printf("%s host could not connect<br>", $hosts[$index]); //debug only
$index++;
}
if (!$connection) {
$this->error_handler("SMTP Error: could not connect to SMTP host server(s)");
return false;
}
// Must perform HELO before authentication
$smtp->Hello($this->Helo);
// If user requests SMTP authentication
if ($this->SMTPAuth) {
if (!$smtp->Authenticate($this->Username, $this->Password)) {
$this->error_handler("SMTP Error: Could not authenticate");
return false;
}
}
if ($this->Sender == "") {
$smtp_from = $this->From;
} else {
$smtp_from = $this->Sender;
}
if (!$smtp->Mail(sprintf("<%s>", $smtp_from))) {
$e = sprintf("SMTP Error: From address [%s] failed", $smtp_from);
$this->error_handler($e);
return false;
}
// Attempt to send attach all recipients
for ($i = 0; $i < count($this->to); $i++) {
if (!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) {
$bad_rcpt[] = $this->to[$i][0];
}
}
for ($i = 0; $i < count($this->cc); $i++) {
if (!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) {
$bad_rcpt[] = $this->cc[$i][0];
}
}
for ($i = 0; $i < count($this->bcc); $i++) {
if (!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) {
$bad_rcpt[] = $this->bcc[$i][0];
}
}
// Create error message
if (count($bad_rcpt) > 0) {
for ($i = 0; $i < count($bad_rcpt); $i++) {
if ($i != 0) {
$e .= ", ";
}
$e .= $bad_rcpt[$i];
}
$e = sprintf("SMTP Error: The following recipients failed [%s]", $e);
$this->error_handler($e);
return false;
}
if (!$smtp->Data(sprintf("%s%s", $header, $body))) {
$this->error_handler("SMTP Error: Data not accepted");
return false;
}
$smtp->Quit();
return true;
}
示例12: ProcessFrontend
public function ProcessFrontend()
{
global $sso_provider, $sso_settings, $sso_target_url, $sso_header, $sso_footer, $sso_providers, $sso_selectors_url;
require_once SSO_ROOT_PATH . "/" . SSO_PROVIDER_PATH . "/" . $sso_provider . "/facebook.php";
$facebook = new SSO_FacebookSDK(array("appId" => $sso_settings["sso_facebook"]["app_id"], "secret" => $sso_settings["sso_facebook"]["app_secret"]));
$id = $facebook->getUser();
if ($id) {
try {
// Calculate the required fields.
$fields = array("id" => true, "first_name" => true, "last_name" => true);
foreach (self::$fieldmap as $key => $info) {
if ($sso_settings["sso_facebook"]["map_" . $key] != "" && !isset($info["pseudo"])) {
$fields[isset($info["parent"]) ? $info["parent"] : $key] = true;
}
}
$profile = $facebook->api("/me", "GET", array("fields" => implode(",", array_keys($fields))));
} catch (FacebookApiException $e) {
// Fall through here to go to the next step.
$id = 0;
$exceptionmessage = $e->getMessage();
}
}
if (isset($_REQUEST["sso_facebook_action"]) && $_REQUEST["sso_facebook_action"] == "signin") {
if ($id) {
// Create a fake username based on available information.
if ($sso_settings["sso_facebook"]["map_username"] != "") {
if (isset($profile["email"])) {
$profile["username"] = (string) @substr($profile["email"], 0, strpos($profile["email"], "@"));
} else {
if (isset($profile["first_name"]) && isset($profile["last_name"])) {
$profile["username"] = $profile["first_name"] . @substr($profile["last_name"], 0, 1);
} else {
if (isset($profile["name"])) {
$name = explode(" ", $name);
$profile["username"] = $name[0] . @substr($name[count($name) - 1], 0, 1);
} else {
$profile["username"] = (string) $id;
}
}
}
$profile["username"] = preg_replace('/\\s+/', "_", trim(preg_replace('/[^a-z0-9]/', " ", strtolower((string) $profile["username"]))));
}
// Check username blacklist.
$message = "";
if (isset($profile["username"])) {
$blacklist = explode("\n", str_replace("\r", "\n", $sso_settings["sso_facebook"]["username_blacklist"]));
foreach ($blacklist as $word) {
$word = trim($word);
if ($word != "" && stripos($profile["username"], $word) !== false) {
$message = BB_Translate("Username contains a blocked word.");
break;
}
}
}
// Check e-mail domain blacklist.
if (isset($profile["email"])) {
define("CS_TRANSLATE_FUNC", "BB_Translate");
require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/smtp.php";
$email = SMTP::MakeValidEmailAddress($profile["email"]);
if (!$email["success"]) {
$message = BB_Translate("Invalid e-mail address. %s", $email["error"]);
} else {
$domain = strtolower(substr($email["email"], strrpos($email["email"], "@") + 1));
$y = strlen($domain);
$baddomains = explode("\n", strtolower($sso_settings["sso_facebook"]["email_bad_domains"]));
foreach ($baddomains as $baddomain) {
$baddomain = trim($baddomain);
if ($baddomain != "") {
$y2 = strlen($baddomain);
if ($domain == $baddomain || $y < $y2 && substr($domain, $y - $y2 - 1, 1) == "." && substr($domain, $y - $y2) == $baddomain) {
$message = BB_Translate("E-mail address is in a blacklisted domain.");
break;
}
}
}
}
}
if ($message == "") {
// Fix birthday to be in international format YYYY-MM-DD.
if (isset($profile["birthday"])) {
$birthday = explode("/", $profile["birthday"]);
$year = array_pop($birthday);
array_unshift($birthday, $year);
$profile["birthday"] = implode("-", $birthday);
}
// Convert most profile fields into strings.
foreach ($profile as $key => $val) {
if (is_string($val)) {
continue;
}
if (is_bool($val)) {
$val = (string) (int) $val;
} else {
if (is_numeric($val)) {
$val = (string) $val;
} else {
if (is_object($val) && isset($val->id) && isset($val->name)) {
$val = $val->name;
}
}
//.........这里部分代码省略.........
示例13: send_email
function send_email($goingto, $toname, $sbj, $messg)
{
global $Config;
define('DISPLAY_XPM4_ERRORS', true);
// display XPM4 errors
$core_em = $Config->get('site_email');
// If email type "0" (SMTP)
if ($Config->get('email_type') == 0) {
require_once 'core/mail/SMTP.php';
// path to 'SMTP.php' file from XPM4 package
$f = '' . $core_em . '';
// from mail address
$t = '' . $goingto . '';
// to mail address
// standard mail message RFC2822
$m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: ' . $sbj . "\r\n" . 'Content-Type: text/plain' . "\r\n\r\n" . '' . $messg . '';
$h = explode('@', $t);
// get client hostname
$c = SMTP::MXconnect($h[1]);
// connect to SMTP server (direct) from MX hosts list
$s = SMTP::Send($c, array($t), $m, $f);
// send mail
// print result
if ($s) {
output_message('success', 'Mail Sent!');
} else {
output_message('error', print_r($_RESULT));
}
SMTP::Disconnect($c);
// disconnect
} elseif ($Config->get('email_type') == 1) {
require_once 'core/mail/MIME.php';
// path to 'MIME.php' file from XPM4 package
// compose message in MIME format
$mess = MIME::compose($messg);
// send mail
$send = mail($goingto, $sbj, $mess['content'], 'From: ' . $core_em . '' . "\n" . $mess['header']);
// print result
echo $send ? output_message('success', 'Mail Sent!') : output_message('error', 'Error!');
} elseif ($Config->get('email_type') == 2) {
require_once 'core/mail/MAIL.php';
// path to 'MAIL.php' file from XPM4 package
$m = new MAIL();
// initialize MAIL class
$m->From($core_em);
// set from address
$m->AddTo($goingto);
// add to address
$m->Subject($sbj);
// set subject
$m->Html($messg);
// set html message
// connect to MTA server 'smtp.hostname.net' port '25' with authentication: 'username'/'password'
if ($Config->get('email_use_secure') == 1) {
$c = $m->Connect($Config->get('email_smtp_host'), $Config->get('email_smtp_port'), $Config->get('email_smtp_user'), $Config->get('email_smtp_pass'), $Config->get('email_smtp_secure')) or die(print_r($m->Result));
} else {
$c = $m->Connect($Config->get('email_smtp_host'), $Config->get('email_smtp_port'), $Config->get('email_smtp_user'), $Config->get('email_smtp_pass')) or die(print_r($m->Result));
}
// send mail relay using the '$c' resource connection
echo $m->Send($c) ? output_message('success', 'Mail Sent!') : output_message('error', 'Error! Please check your config and make sure you inserted your MTA info correctly.');
$m->Disconnect();
// disconnect from server
// print_r($m->History); // optional, for debugging
}
}
示例14: sendemail
function sendemail()
{
global $msg, $required;
if (isset($_POST['ajax'])) {
$ajax = $_POST['ajax'];
} else {
$ajax = false;
}
if (isset($_POST['action']) and $_POST['action'] == 'sendmail') {
$body = BODY;
$subject = SUBJECT;
$post_data = array_map('stripslashes', $_POST);
// print_r($post_data);
// die;
foreach ($required as $id_field) {
if ($post_data[$id_field] == '' || is_null($post_data[$id_field])) {
if ($ajax) {
end_ajax($msg['error']);
} else {
redirect(ERROR_URL);
}
}
}
if (!is_email($post_data['email']) or $post_data['email'] == '') {
if ($ajax) {
end_ajax($msg['error']);
} else {
redirect(ERROR_URL);
}
}
foreach ($post_data as $id => $var) {
if ($id == 'message') {
$var = nl2br($var);
}
$body = str_replace("%{$id}%", $var, $body);
}
$subject = str_replace("%messagetype%", $post_data['messagetype'], $subject);
require_once "fzo.mail.php";
$mail = new SMTP("localhost", "info@grangaleriadevoto.com", "Refrescola09");
$headers = $mail->make_header(FROM_EMAIL, TO_EMAIL, $subject, 3, $cc, $bcc);
$headers .= 'mime-version: 1.0' . "\r\n";
$headers .= 'content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "Reply-To: " . $post_data['email'] . " \r\n";
/* Pueden definirse más encabezados. Tener en cuenta la terminación de la linea con (\r\n) $header .= "Reply-To: ".$_POST['from']." \r\n"; $header .= "Content-Type: text/plain; charset=\"iso-8859-1\" \r\n"; $header .= "Content-Transfer-Encoding: 8bit \r\n"; $header .= "MIME-Version: 1.0 \r\n"; */
$error = $mail->smtp_send(FROM_EMAIL, TO_EMAIL, $headers, $body, $cc, $bcc);
// $sendmail = mail( TO_EMAIL, SUBJECT, $body, $headers );
if ($error == "0") {
if ($ajax) {
end_ajax($msg['success']);
} else {
redirect(SUCCESS_URL);
}
} else {
if ($ajax) {
end_ajax($msg['not-sent']);
} else {
redirect(NOTSENT_URL);
}
}
}
}
示例15: 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);