本文整理汇总了PHP中htmlMimeMail::setHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP htmlMimeMail::setHeader方法的具体用法?PHP htmlMimeMail::setHeader怎么用?PHP htmlMimeMail::setHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htmlMimeMail
的用法示例。
在下文中一共展示了htmlMimeMail::setHeader方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: EmailSuppliers
function EmailSuppliers()
{
$EmailText = _('This email has been automatically generated by KwaMoja') . "\n";
$EmailText .= _('You are invited to Tender for the following products to be delivered to') . ' ' . $_SESSION['CompanyRecord']['coyname'] . "\n";
$EmailText .= _('Tender number') . ': ' . $this->TenderId . "\n";
$EmailText .= _(' Quantity ') . ' ' . _(' Unit ') . ' ' . _(' Item Description') . "\n";
foreach ($this->LineItems as $LineItem) {
$EmailText .= $LineItem->Quantity . ' ' . $LineItem->Units . ' ' . $LineItem->ItemDescription . "\n";
}
$Subject = _('Tender received from') . ' ' . $_SESSION['CompanyRecord']['coyname'];
$Headers = 'From: ' . $_SESSION['PurchasingManagerEmail'] . "\r\n" . 'Reply-To: ' . $_SESSION['PurchasingManagerEmail'] . "\r\n" . 'X-Mailer: PHP/' . phpversion();
if ($_SESSION['SmtpSetting'] == 1) {
include 'includes/htmlMimeMail.php';
$mail = new htmlMimeMail();
$mail->setText($EmailText);
$mail->setSubject($Subject);
$mail->setFrom($_SESSION['PurchasingManagerEmail']);
$mail->setHeader('Reply-To', $_SESSION['PurchasingManagerEmail']);
$mail->setCc($_SESSION['PurchasingManagerEmail']);
//Set this as a copy for filing purpose
}
foreach ($this->Suppliers as $Supplier) {
$result = mail($Supplier->EmailAddress, $Subject, $EmailText, $Headers);
if ($_SESSION['SmtpSetting'] == 0) {
$result = mail($Supplier->EmailAddress, $Subject, $EmailText, $Headers);
} else {
$result = SendmailBySmtp($mail, array($Supplier->EmailAddress, $_SESSION['PurchasingManagerEmail']));
}
}
}
示例2: send
public static function send($from, $to, $subject, $body, array $attachments = null, array $headers = null)
{
if (empty($to)) {
Logger::trace("mail not sent: no recipients: {$subject}");
return;
}
$config = Context::last()->config;
if (empty($from)) {
if (!($from = $config->get('modules/mail/from'))) {
$from = "Molinos.CMS <no-reply@" . MCMS_HOST_NAME . ">";
}
}
if (strstr($body, '<html>') === false) {
$body = '<html><head><title>' . html::plain($subject) . '</title></head><body>' . $body . '</body></html>';
}
if (!is_array($to)) {
$to = preg_split('/, */', $to, -1, PREG_SPLIT_NO_EMPTY);
}
Logger::log(sprintf('to=%s, subject=%s', join(',', $to), $subject), 'mail');
$mail = new htmlMimeMail();
if ('smtp' == ($transport = ($server = $config->get('modules/mail/server')) ? 'smtp' : 'mail')) {
$mail->setSMTPParams($server);
}
$mail->setFrom($from);
$mail->setSubject($subject);
$mail->setHtml(self::fixhtml($body));
$mail->setTextCharset('UTF-8');
$mail->setTextEncoding('base64');
$mail->setHTMLCharset('UTF-8');
$mail->setHTMLEncoding('UTF-8');
$mail->setHeadCharset('UTF-8');
foreach ((array) $attachments as $file) {
$mail->addAttachment($file['data'], $file['name'], $file['type']);
}
foreach ((array) $headers as $k => $v) {
if (!empty($v)) {
$mail->setHeader($k, $v);
}
}
return $mail->send($to, $transport);
}
示例3: SendHtmlEmail
function SendHtmlEmail($plantilla, $variables, $subject, $destino, $origen = "presupuestos@pachecoforja.com", $imagenes = NULL, $imgdir = "img", $html = NULL)
{
require_once 'mail.php';
if (!$html) {
$smarty = SmartyInit();
$smarty->assign("variables", $variables);
$body = $smarty->fetch($plantilla);
} else {
$body = $html;
}
$mail = new htmlMimeMail();
// Definimos el html
$mail->setHtml($body);
// Comprobamos si hay imagenes embebidas en el correo
if ($imagenes != NULL) {
// Leemos todos los ficheros y los aadimos al correo
foreach ($imagenes as $imagen) {
$len = strlen($imagen);
$extension = substr($imagen, $len - 3, 3);
if ($extension == "gif") {
$tipo = "image/gif";
}
if ($extension == "jpg") {
$tipo = "image/jpg";
}
$fichero = $imgdir . "/" . $imagen;
$temp = $mail->getFile($fichero);
$mail->addHtmlImage($temp, $imagen, $tipo);
}
}
// Definimos las cabeceras de los mensajes
$mail->setReturnPath($origen);
$mail->setFrom($origen);
$mail->setSubject($subject);
$mail->setHeader('X-Mailer', 'Correo enviado por pachecoforja.com');
// Enviamos el correo
$result = $mail->send(array($destino), 'smtp');
if (!$result) {
return $mail->errors;
} else {
return true;
}
}
示例4: class
* (case-sensitive) to the name in the html.
*/
$mail->setHtml($html, $text);
$mail->addHtmlImage($background, 'background.gif', 'image/gif');
/*
* This is used to add an attachment to
* the email. Due to above, the $attachment
* variable contains the example zip file.
*/
$mail->addAttachment($attachment, 'example.zip', 'application/zip');
/*
* Set the return path of the message
*/
$mail->setReturnPath('joe@example.com');
/**
* Set some headers
*/
$mail->setFrom('"Joe" <joe@example.com>');
$mail->setSubject('Test mail');
$mail->setHeader('X-Mailer', 'HTML Mime mail class (http://www.phpguru.org)');
/**
* Send it using SMTP. If you're using Windows you should *always* use
* the smtp method of sending, as the mail() function is buggy.
*/
$result = $mail->send(array('postmaster@localhost'), 'smtp');
// These errors are only set if you're using SMTP to send the message
if (!$result) {
print_r($mail->errors);
} else {
echo 'Mail sent!';
}
示例5: fErrorSQL
$cSql = "SELECT "
. " NwsSuscCodigo, NwsSuscNombre, NwsSuscMail "
. "FROM NwsSuscriptores "
. "WHERE " . $cFiltro . " "
. "LIMIT " . $nCuantos ;
$nResultado = mysql_query ($cSql) or fErrorSQL($conf["EstadoSitio"], "<br /><br /><b>Error en la consulta:</b><br />" . $cSql . "<br /><br /><b>Tipo de error:</b><br />" . mysql_error() . "<br />");
$nFilasTot = mysql_num_rows($nResultado) ;
$nFilasAct = 0 ;
while ($aRegistro = mysql_fetch_array($nResultado)) {
$nFilasAct++ ;
$oMail = new htmlMimeMail();
$oMail->setHeader('X-Mailer', 'HTML Mime mail');
$oMail->setHeader('MIME-Version', '1.0');
// $oMail->setHeader('Content-type', 'text/html;charset=ISO-8859-9');
// $oMail->setTextCharset("utf-8");
// $oMail->setHTMLCharset("utf-8");
// $oMail->setHeadCharset("utf-8");
$cTexto = $oMail->getFile("./Newsletter/Newsletter.txt");
$cTexto = str_replace("##Contenido##", $cContTexto, $cTexto);
$cTexto = str_replace("##Nombre##", $aRegistro["NwsSuscNombre"], $cTexto);
$cTexto = str_replace("##EMail##", $aRegistro["NwsSuscMail"], $cTexto);
$cTexto = str_replace("##ClaveBaja##", md5("#".$aRegistro["NwsSuscCodigo"]."#".$aRegistro["NwsSuscMail"]."#"), $cTexto);
$cHTML = $oMail->getFile("./Newsletter/Newsletter.html");
$cHTML = str_replace("##Contenido##", $cContHTML, $cHTML);
$cHTML = str_replace("##Nombre##", $aRegistro["NwsSuscNombre"], $cHTML);
示例6: send_mail
/**
* Send e-mails
*
* @param String $to Recipient mail address
* @param String $subject Subject
* @param String $message Mail content
* @param String $from Sender mail address
* @param Array $headers Additional mail headers
*
* @return Bool Returs true if mail has been sent
*/
function send_mail($to, $subject, $message, $from, $headers = NULL)
{
global $configuration;
$mail = new htmlMimeMail();
if ($configuration['mail_type'] == 'smtp') {
$type = 'smtp';
$smtp = $configuration['smtp'];
$mail->setSMTPParams($smtp['host'], $smtp['port'], $smtp['helo'], $smtp['auth'], $smtp['user'], $smtp['pass']);
} else {
$type = 'mail';
}
// Set additional mail headers
$html = false;
if (is_array($headers)) {
foreach ($headers as $name => $value) {
$mail->setHeader($name, $value);
if (strtolower($name) == 'content-type' and preg_match('#text/html#i', $value)) {
$mail->setHtmlCharset($configuration['character_set']);
$mail->setHtml($message);
$html = true;
}
// Set return path
if (strtolower($name) == 'return-path') {
$mail->setReturnPath($value);
}
}
}
$mail->setHeadCharset($configuration['character_set']);
$mail->setFrom($from);
$mail->setSubject($subject);
if ($html != true) {
$configuration['character_set'];
$mail->setTextCharset($configuration['character_set']);
$mail->setText($message);
}
$result = $mail->send(array($to), $type);
if ($result) {
return true;
}
}
示例7: forgotPassword
function forgotPassword($email)
{
global $bigtree;
$home_page = sqlfetch(sqlquery("SELECT `nav_title` FROM `bigtree_pages` WHERE id = 0"));
$site_title = $home_page["nav_title"];
$no_reply_domain = str_replace(array("http://www.", "https://www.", "http://", "https://"), "", DOMAIN);
$email = sqlescape($email);
$user = sqlfetch(sqlquery("SELECT * FROM bigtree_users WHERE email = '{$email}'"));
if (!$user) {
return false;
}
$hash = sqlescape(md5(md5(md5(uniqid("bigtree-hash" . microtime(true))))));
sqlquery("UPDATE bigtree_users SET change_password_hash = '{$hash}' WHERE id = '" . $user["id"] . "'");
$login_root = ($bigtree["config"]["force_secure_login"] ? str_replace("http://", "https://", ADMIN_ROOT) : ADMIN_ROOT) . "login/";
$html = file_get_contents(BigTree::path("admin/email/reset-password.html"));
$html = str_ireplace("{www_root}", WWW_ROOT, $html);
$html = str_ireplace("{admin_root}", ADMIN_ROOT, $html);
$html = str_ireplace("{site_title}", $site_title, $html);
$html = str_ireplace("{reset_link}", $login_root . "reset-password/{$hash}/", $html);
$text = "Password Reset:\n\nPlease visit the following link to reset your password:\n{$reset_link}\n\nIf you did not request a password change, please disregard this email.\n\nYou are receiving this because the address is linked to an account on {$site_title}.";
$mailer = new htmlMimeMail();
$mailer->setFrom('"BigTree CMS" <no-reply@' . $no_reply_domain . '>');
$mailer->setSubject("Reset Your Password");
$mailer->setHeader('X-Mailer', 'HTML Mime mail class (http://www.phpguru.org)');
$mailer->setHtml($html, $text);
$mailer->send(array($user["email"]));
BigTree::redirect($login_root . "forgot-success/");
}
示例8: stripslashes
//.........这里部分代码省略.........
if (trim(str_replace('X-Form-Mail-Attachment:', '', $header_info[$k])) == 'no') {
$send_attachments = false;
}
unset($header_info[$k]);
continue;
}
if (preg_match("/^" . $mail_header . "/i", $header_info[$k], $match)) {
$additional_headers[] = $header_info[$k];
$attachment_headers[str_replace(':', '', $match[0])] = trim(preg_replace("/" . $match[0] . "/i", '', $header_info[$k]));
unset($header_info[$k]);
continue;
}
}
if (isset($header_info) and is_array($header_info)) {
$new_mail_content = trim(implode($header_info, "\n"));
$new_mail_content = str_replace("\r", '', $new_mail_content);
} else {
$new_mail_content = '';
}
// if (isset($additional_headers) and is_array($additional_headers)) {
// $additional_headers = implode($additional_headers, "\n");
// } else {
// $additional_headers = '';
// }
/**
* Wrap mail content (and only mail content - not
* headers).
*/
$new_mail_content = $this->wrap_content($new_mail_content, $text_wrap);
/**
* Send mail using simple mail function
*/
if (!$send_attachments and $debug_mode != 'on' and $mail_recipient != '') {
// @mail ($mail_recipient, $mail_subject, $new_mail_content, $additional_headers);
send_mail($mail_recipient, $mail_subject, $new_mail_content, $mail_from, $attachment_headers);
}
/**
* Send mail using mail class
*/
if ($send_attachments and $debug_mode != 'on' and $mail_recipient != '') {
$att = new htmlMimeMail();
// Switch to smtp mode
if ($configuration['mail_type'] == 'smtp') {
$type = 'smtp';
$smtp = $configuration['smtp'];
$att->setSMTPParams($smtp['host'], $smtp['port'], $smtp['helo'], $smtp['auth'], $smtp['user'], $smtp['pass']);
} else {
$type = 'mail';
}
// Register file attachments in mime class
foreach ($this->attachments as $file_name) {
$att->addAttachment($att->getFile($file_name['new']), $file_name['old']);
}
//Manage mail var attachments
if (isset($configuration['attach_mail_vars']) and is_array($configuration['attach_mail_vars']) and sizeof($configuration['attach_mail_vars']) > 0) {
foreach ($configuration['attach_mail_vars'] as $attach_type) {
if ($attach_type == 'vcard') {
$attach_config = array('mailvars' => $post_data, 'type' => G10E_ATTACH_TYPE_VCARD, 'control' => $this->control_fields);
if ($res = attach_mail_variables::get_content($attach_config)) {
$att->addAttachment($res, 'vcard.vcf');
}
}
if ($attach_type == 'csv') {
$attach_config = array('mailvars' => $post_data, 'type' => G10E_ATTACH_TYPE_CSV, 'control' => $this->control_fields, 'csv_head' => true);
if ($res = attach_mail_variables::get_content($attach_config)) {
$att->addAttachment($res, 'csv.csv');
}
}
}
}
// Register headers in mime class
$html = false;
if (isset($attachment_headers) and is_array($attachment_headers)) {
foreach ($attachment_headers as $key => $val) {
$att->setHeader($key, $val);
if ($key == 'Content-Type' and preg_match('#text/html#i', $val)) {
$att->setHtmlCharset($configuration['character_set']);
$att->setHtml($new_mail_content);
$html = true;
}
}
}
$att->setHeadCharset($configuration['character_set']);
$att->setSubject($mail_subject);
if ($html != true) {
$att->setTextCharset($configuration['character_set']);
$att->setText($new_mail_content);
}
$att->send(array($mail_recipient), $type);
}
debug_mode($mail_recipient, 'Mail Recipient mail()');
debug_mode($mail_subject, 'Mail Subject mail()');
debug_mode($new_mail_content, 'Mail Content mail()');
debug_mode($additional_headers, 'Mail Additional Headers mail()');
}
}
// -re- for
$this->mail_content = $mail_content[0];
return array('status' => 'ok', 'mail_content' => $this->mail_content);
}
示例9: EmailOffer
function EmailOffer()
{
$Subject = _('Offer received from') . ' ' . $this->GetSupplierName();
$Message = _('This email is automatically generated by webERP') . "\n" . _('You have received the following offer from') . ' ' . $this->GetSupplierName() . "\n\n" . $this->OfferMailText;
$Headers = 'From: ' . $this->GetSupplierEmail() . "\r\n" . 'Reply-To: ' . $this->GetSupplierEmail() . "\r\n" . 'X-Mailer: PHP/' . phpversion();
if ($_SESSION['SmtpSetting'] == 1) {
include 'includes/htmlMimeMail.php';
$mail = new htmlMimeMail();
$mail->setText($Message);
$mail->setSubject($Subject);
$mail->setFrom($this->GetSupplierEmail());
$mail->setHeader('Reply-To', $this->GetSupplierEmail());
$mail->setCc($this->GetSupplierEmail());
}
if ($_SESSION['SmtpSetting'] == 0) {
$result = mail($_SESSION['PurchasingManagerEmail'], $Subject, $Message, $Headers);
} else {
$result = SendmailBySmtp($mail, array($Supplier->EmailAddress, $_SESSION['PurchasingManagerEmail']));
}
return $result;
}
示例10: sendEmail
static function sendEmail($to, $subject, $html, $text = "", $from = false, $return = false, $cc = false, $bcc = false, $headers = array())
{
$mailer = new htmlMimeMail();
$headers["X-Mailer"] = "BigTree CMS (http://www.bigtreecms.org) + HTML Mime mail class (http://www.phpguru.org)";
foreach ($headers as $key => $val) {
$mailer->setHeader($key, $val);
}
$mailer->setSubject($subject);
$mailer->setHtml($html, $text);
if (!$from) {
$from = "no-reply@" . (isset($_SERVER["HTTP_HOST"]) ? str_replace("www.", "", $_SERVER["HTTP_HOST"]) : str_replace(array("http://www.", "https://www.", "http://", "https://"), "", DOMAIN));
}
$mailer->setFrom($from);
if ($return) {
$mailer->setReturnPath($return);
}
if ($cc) {
$mailer->setCc(is_array($cc) ? $cc : array($cc));
}
if ($bcc) {
$mailer->setBcc(is_array($bcc) ? $bcc : array($bcc));
}
return $mailer->send(is_array($to) ? $to : array($to));
}
示例11: send_mail_new
function send_mail_new($to_name, $to_email, $from_name = "", $from_email = "", $subject = "", $message, $mail_type = "", $att_ids = "", $bcc_email = "", $cc_email = "", $reply = "", $f_type = "")
{
//require_once 'swift/lib/swift_required.php';
global $Site_Name;
global $AdminName;
global $AdminMail;
global $AdminToName;
global $AdminToEmail;
global $USESENDGRID;
if ($from_name == "") {
$from_name = $AdminName;
}
if ($from_email == "") {
$from_email = $AdminMail;
}
if ($to_name == "") {
$to_name = $AdminToName;
}
if ($to_email == "") {
$to_email = $AdminToEmail;
}
$message = str_replace("\\n", "\\r\\n", $message);
$from = "{$from_name} <{$from_email}>";
$to = "{$to_name} <{$to_email}>";
if ($USESENDGRID == 0) {
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: {$from}\n";
if ($reply) {
$headers .= "Reply-To: {$reply} \n";
}
if ($cc_email) {
$headers .= "CC: {$cc_email} \n";
}
$headers .= "BCC: " . $bcc_email;
if ($att_ids != "" && $f_type != '') {
$mail = new htmlMimeMail();
$mail->setSubject($subject);
//$mail->setText($message);
$mail->setHtml($message);
$mail->setFrom($from);
if ($cc_email) {
$mail->setCc($cc_email);
}
if ($bcc_email) {
$mail->setBcc($bcc_email);
}
if ($reply) {
$mail->setHeader("Return-Path", $reply);
$mail->setHeader("Reply-To", $reply);
}
$result = $mail->send(array($to));
//print $result;
} else {
@mail($to, $subject, $message, $headers);
}
} else {
global $Sendgrid_Email, $Sendgrid_Pass;
$transport = Swift_SmtpTransport::newInstance('smtp.sendgrid.net', 25)->setUsername($Sendgrid_Email)->setPassword($Sendgrid_Pass);
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
$orig_msg = $message;
//Create a message
$message = Swift_Message::newInstance($subject)->setFrom(array($from_email => $from_name))->setTo(array($to_email => $to_name));
$message->setSender($from_email);
$message->setBody($orig_msg, 'text/html');
if ($reply) {
$message->setReplyTo($reply);
}
if ($cc_email) {
$message->setCc($cc_email);
}
if ($bcc_email) {
$message->addBcc($bcc_email);
}
//Send the message
$result = $mailer->send($message);
}
}
示例12: _createMailer
/**
* Initialise un objet htmlMimeMail pour l'envoi.
*
* @return htmlMimeMail
*/
private function _createMailer()
{
Copix::RequireOnce(COPIX_PATH . '../htmlMimeMail/htmlMimeMail.php');
$mail = new htmlMimeMail();
$mail->setReturnPath(CopixConfig::get('|mailFrom'));
$mail->setFrom('"' . CopixConfig::get('|mailFromName') . '" <' . CopixConfig::get('|mailFrom') . '>');
$mail->setHeader('X-Mailer', 'COPIX (http://copix.org) with HTML Mime mail class (http://www.phpguru.org)');
if (CopixConfig::get('|mailMethod') == 'smtp') {
$auth = CopixConfig::get('|mailSmtpAuth') == '' ? null : CopixConfig::get('|mailSmtpAuth');
$pass = CopixConfig::get('|mailSmtpPass') == '' ? null : CopixConfig::get('|mailSmtpPass');
$hasAuth = $auth != null;
$port = CopixConfig::exists('|mailSmtpPort') && CopixConfig::get('|mailSmtpPort') ? CopixConfig::get('|mailSmtpPort') : null;
$mail->setSMTPParams(CopixConfig::get('|mailSmtpHost'), $port, null, $hasAuth, $auth, $pass);
}
return $mail;
}