当前位置: 首页>>代码示例>>PHP>>正文


PHP Mail_mime::addHTMLImage方法代码示例

本文整理汇总了PHP中Mail_mime::addHTMLImage方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail_mime::addHTMLImage方法的具体用法?PHP Mail_mime::addHTMLImage怎么用?PHP Mail_mime::addHTMLImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mail_mime的用法示例。


在下文中一共展示了Mail_mime::addHTMLImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 function send()
 {
     $headers = array('From' => $this->from, 'To' => $this->to, 'Subject' => $this->subject);
     $mime = new Mail_mime(array('eol' => "\n"));
     $mime->setHTMLBody($this->html);
     foreach ($this->images as $image) {
         $sucess[] = $mime->addHTMLImage($image, "image/png");
     }
     $smtp = Mail::factory('smtp', array('host' => $this->host, 'auth' => true, 'username' => $this->u, 'password' => $this->p));
     $body = $mime->get();
     $headers = $mime->headers($headers);
     $mail = $smtp->send($this->to, $headers, $body);
     if (PEAR::isError($mail)) {
         //echo("<p>" . $mail->getMessage() . "</p>");
         return false;
     }
     return true;
 }
开发者ID:makeadiff,项目名称:exdon,代码行数:18,代码来源:Email.php

示例2: send

 /**
  * Send the ecard.
  */
 public function send($id)
 {
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     if (!ecard::can_send_ecard()) {
         access::forbidden();
     }
     $form = ecard::get_send_form($item);
     try {
         $valid = $form->validate();
     } catch (ORM_Validation_Exception $e) {
         // Translate ORM validation errors into form error messages
         foreach ($e->validation->errors() as $key => $error) {
             $form->edit_item->inputs[$key]->add_error($error, 1);
         }
         $valid = false;
     }
     if ($valid) {
         $v = new View("ecard_email.html");
         $v->item = $item;
         $v->subject = module::get_var("ecard", "subject");
         $to_name = $form->send_ecard->to_name->value;
         $from_name = $form->send_ecard->from_name->value;
         $bcc = module::get_var("ecard", "bcc");
         $v->message = t(module::get_var("ecard", "message"), array("toname" => $to_name, "fromname" => $from_name));
         $v->custom_message = $form->send_ecard->text->value;
         $v->image = $item->name;
         $to = $form->send_ecard->inputs["to_email"]->value;
         $from = $form->send_ecard->inputs["from_email"]->value;
         $headers = array("from" => $from_name . "<" . $from . ">", "to" => $to, "subject" => module::get_var("ecard", "subject"));
         require_once MODPATH . "ecard/lib/mime.php";
         $mime = new Mail_mime("\n");
         $mime->setHTMLBody($v->render());
         $mime->addHTMLImage($item->resize_path(), $item->mime_type, $item->name);
         $body = $mime->get(array('html_charset' => 'UTF-8', 'text_charset' => 'UTF-8', 'text_encoding' => '8bit', 'head_charset' => 'UTF-8'));
         self::_notify($headers['to'], $headers['from'], $headers['subject'], $item, $body, $mime->headers(), $bcc);
         message::success("eCard successfully sent");
         json::reply(array("result" => "success"));
     } else {
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:45,代码来源:ecard.php

示例3: foreach

// Generate image attach
$graphs = json_decode($message_tags_html['ENTITY_GRAPHS_ARRAY'], TRUE);
//print_vars($graphs);
if (is_array($graphs) && count($graphs)) {
    $message_tags_html['ENTITY_GRAPHS'] = '';
    // Reinit graphs html
    foreach ($graphs as $key => $graph) {
        $cid = $graph['type'] . $key;
        // Unencode data uri tag to file content
        list($gmime, $base64) = explode(';', $graph['data'], 2);
        $gmime = substr($gmime, 5);
        $base64 = substr($base64, 7);
        //print_vars(substr($graph['data'], 0, 20));
        //print_vars($gmime);
        //print_vars(substr($base64, 0, 20));
        $mime->addHTMLImage(base64_decode($base64), $gmime, $cid . '.png', FALSE, $cid);
        $message_tags_html['ENTITY_GRAPHS'] .= '<h4>' . $graph['type'] . '</h4>';
        $message_tags_html['ENTITY_GRAPHS'] .= '<a href="' . $graph['url'] . '"><img src="cid:' . $cid . '"></a><br />';
    }
}
//print_vars($message_tags_html);
$message['html'] = simple_template('email_html', $message_tags_html, array('is_file' => TRUE));
unset($message_tags_html);
foreach ($message as $part => $part_body) {
    switch ($part) {
        case 'text':
        case 'txt':
        case 'plain':
            $part_body .= "\n\nE-mail sent to: {$rcpts}\n";
            $part_body .= "E-mail sent at: {$time_sent}\n\n";
            $part_body .= "-- \n" . OBSERVIUM_PRODUCT_LONG . ' ' . OBSERVIUM_VERSION . "\n" . OBSERVIUM_URL . "\n";
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:email.inc.php

示例4: sendMimeEmail

 private function sendMimeEmail($toAddr, $emailBody, $destinationType)
 {
     $crlf = "\r\n";
     $hdrs = array('From' => 'noreply@stlbridalpros.com', 'Subject' => 'Hot Lead - stlbridalpros');
     $mime = new Mail_mime($crlf);
     if ($destinationType == DESTINATIONTYPE::MMSTEXT || $destinationType == DESTINATIONTYPE::SMSTEXT) {
         $mime->setTXTBody($emailBody);
     }
     if ($destinationType == DESTINATIONTYPE::EMAIL) {
         $mime->addHTMLImage("images/stlbridalprosLogo_200x180.jpg", "image/jpeg");
         $cid = $mime->_html_images[count($mime->_html_images) - 1]['cid'];
         $html = '<html><style>.colored{color:#aa0000;}#header{text-align:center;margin-bottom:20px;font-weight:bold;font-size:18px}#headerText{margin-left:15px;}</style><body><div id="header"><img src="cid:' . $cid . '"><span id="headerText"><p>St. Louis Bridal Pros<p><p>Hot Lead</p></span></div>' . $emailBody . '</body></html>';
         $mime->setHTMLBody($html);
     }
     $body = $mime->get();
     $hdrs = $mime->headers($hdrs);
     $mail =& Mail::factory('mail');
     $mail->send($toAddr, $hdrs, $body);
 }
开发者ID:ctwoolsey,项目名称:stlbproWebsite_git,代码行数:19,代码来源:vendorContactFormSubmit.php

示例5: nc_mail2queue

/**
 * Положить письмо в очередь
 *
 * @param string $recipient
 * @param string $from
 * @param string $subject
 * @param string $message
 * @param string HTML-сообщение
 *
 * Чтобы отправить сообщение в формате HTML, нужно указать параметр html_message.
 * При этом параметр message должен содержать сообщение в plain text или может быть пустым
 *
 * Чтобы отправить plain text, параметр html_message нужно оставить пустым.
 */
function nc_mail2queue($recipient, $from, $subject, $message, $html_message = "", $attachment_type = "")
{
    require_once "Mail/Queue.php";
    $db_options = array('type' => 'ezsql', 'mail_table' => 'Mail_Queue');
    $mail_options = array('driver' => 'mail');
    $mail_queue = new Mail_Queue($db_options, $mail_options);
    $hdrs = array('From' => $from, 'Subject' => nc_base64_encode_header($subject));
    $mime = new Mail_mime("\n");
    if ($attachment_type) {
        $nc_core = nc_Core::get_object();
        $db = $nc_core->db;
        $type_escaped = $db->escape($attachment_type);
        $sql = "SELECT `Filename`, `Path`, `Content_Type`, `Extension` FROM `Mail_Attachment` WHERE `Type` = '{$type_escaped}'";
        $attachments = (array) $db->get_results($sql, ARRAY_A);
        while (preg_match('/\\%FILE_([-_a-z0-9]+)/i', $html_message, $match)) {
            $filename = $match[1];
            $file = false;
            foreach ($attachments as $index => $attachment) {
                if (strtolower($attachment['Filename']) == strtolower($filename)) {
                    $file = $attachment;
                    unset($attachments[$index]);
                    break;
                }
            }
            $replace = '';
            if ($file) {
                $absolute_path = $nc_core->DOCUMENT_ROOT . $file['Path'];
                $replace = 'file_' . $filename . '.' . $file['Extension'];
                $mime->addHTMLImage(@file_get_contents($absolute_path), $file['Content_Type'], $replace, false);
            }
            $html_message = preg_replace('/\\%FILE_' . preg_quote($filename) . '/', $replace, $html_message);
        }
        foreach ($attachments as $attachment) {
            $absolute_path = $nc_core->DOCUMENT_ROOT . $attachment['Path'];
            $mime->addAttachment($absolute_path, $attachment['Content_Type'], $attachment['Filename'] . '.' . $attachment['Extension']);
        }
    }
    if ($message) {
        $mime->setTXTBody($message);
    }
    if ($html_message) {
        $mime->setHTMLBody($html_message);
    }
    $body = $mime->get(array('text_encoding' => '8bit', 'html_charset' => MAIN_EMAIL_ENCODING, 'text_charset' => MAIN_EMAIL_ENCODING, 'head_charset' => MAIN_EMAIL_ENCODING));
    $hdrs = $mime->headers($hdrs);
    $mail_queue->put($from, $recipient, $hdrs, $body);
}
开发者ID:Blu2z,项目名称:implsk,代码行数:61,代码来源:mail.inc.php

示例6: send_quarantine_email

function send_quarantine_email($email, $filter, $quarantined)
{
    global $html, $html_table, $html_content, $text, $text_content;
    // Setup variables to prevent warnings
    $h1 = "";
    $t1 = "";
    // Build the quarantine list for this recipient
    foreach ($quarantined as $qitem) {
        // HTML Version
        $h1 .= sprintf($html_content, $qitem['datetime'], $qitem['to'], $qitem['from'], $qitem['subject'], $qitem['reason'], '<a href="' . QUARANTINE_REPORT_HOSTURL . '/viewmail.php?id=' . $qitem['id'] . '">View</a>');
        // Text Version
        $t1 .= sprintf($text_content, strip_tags($qitem['datetime']), $qitem['to'], $qitem['from'], $qitem['subject'], $qitem['reason'], '<a href="' . QUARANTINE_REPORT_HOSTURL . '/viewmail.php?id=' . $qitem['id'] . '">View</a>');
    }
    // HTML
    $h2 = sprintf($html_table, $h1);
    $html_report = sprintf($html, $filter, QUARANTINE_REPORT_DAYS, count($quarantined), QUARANTINE_DAYS_TO_KEEP, $h2);
    if (DEBUG) {
        echo $html_report;
    }
    // Text
    $text_report = sprintf($text, $filter, QUARANTINE_REPORT_DAYS, count($quarantined), QUARANTINE_DAYS_TO_KEEP, $t1);
    if (DEBUG) {
        echo "<pre>{$text_report}</pre>\n";
    }
    // Send e-mail
    $mime = new Mail_mime("\n");
    $hdrs = array('From' => QUARANTINE_REPORT_FROM_NAME . ' <' . QUARANTINE_FROM_ADDR . '>', 'To' => $email, 'Subject' => QUARANTINE_REPORT_SUBJECT, 'Date' => date("r"));
    $mime->addHTMLImage(MAILWATCH_HOME . '/images/mailwatch-logo.png', 'image/png', 'mailwatch-logo.png', true);
    $mime->setTXTBody($text_report);
    $mime->setHTMLBody($html_report);
    $body = $mime->get();
    $hdrs = $mime->headers($hdrs);
    $mail_param = array('host' => QUARANTINE_MAIL_HOST);
    $mail =& Mail::factory('smtp', $mail_param);
    $mail->send($email, $hdrs, $body);
    dbg(" ==== Sent e-mail to {$email}");
}
开发者ID:thctlo,项目名称:1.2.0,代码行数:37,代码来源:quarantine_report.php

示例7: send

 /**
  * Send mail
  *
  * @return boolean
  */
 public function send()
 {
     if (!strlen($this->_transferMethod)) {
         throw new Gpf_Exception('Mail Transfer Method not set!');
     }
     if (!strlen($this->_recipients)) {
         throw new Gpf_Exception($this->_("Recipients empty"));
     }
     if (!($method = $this->createMethod($this->_transferMethod, $this->_transferParams))) {
         throw new Gpf_Exception("Cannot instantiate mail method: " . $this->_transferMethod);
     }
     $mail = new Mail_mime("\n");
     $mail->_build_params['html_charset'] = 'UTF-8';
     $mail->_build_params['text_charset'] = 'UTF-8';
     $mail->_build_params['head_charset'] = 'UTF-8';
     if (defined('MAIL_HEADER_ENCODING_BASE64')) {
         $mail->_build_params['head_encoding'] = 'base64';
     }
     if (strlen($this->_htmlbody)) {
         $mail->setHTMLBody($this->_htmlbody);
         if (strlen($this->_txtbody)) {
             $mail->setTXTBody($this->_txtbody);
         } else {
             $mail->setTXTBody(Gpf_Mail_Html2Text::convert($this->_htmlbody));
         }
     } else {
         if (strlen($this->_txtbody)) {
             $mail->setTXTBody($this->_txtbody);
         } else {
             throw new Gpf_Exception($this->_("Body of mail not specified"));
         }
     }
     foreach ($this->_attachments as $attachment) {
         if (is_array($attachment)) {
             if (strlen($attachment['content'])) {
                 $ret = $mail->addAttachment($attachment['content'], $attachment['filetype'], $attachment['filename'], false);
             } else {
                 $ret = $mail->addAttachment($attachment['filename'], $attachment['filetype'], $attachment['filename'], true);
             }
         } else {
             throw new Gpf_Exception('Unknown attachment type');
         }
         if (PEAR::isError($ret)) {
             throw new Gpf_Exception("Adding attachment error: " . $ret->getMessage());
         }
     }
     foreach ($this->_images as $image) {
         if (strlen($image['content'])) {
             $ret = $mail->addHTMLImage($image['content'], $this->getImageContentType($image['filename']), $image['filename'], false);
         } else {
             $ret = $mail->addHTMLImage($image['filename'], $this->getImageContentType($image['filename']), $image['filename'], true);
         }
         if (PEAR::isError($ret)) {
             throw new Gpf_Exception("Adding image error: " . $ret->getMessage());
         }
     }
     if (!$this->initHeaders()) {
         throw new Gpf_Exception($this->_('Failed to init mail headers'));
     }
     if (!$method instanceof Mail) {
         throw new Gpf_Exception($this->_('Email transfer method error'));
     }
     $body = $mail->get();
     $ret = $method->send($this->_recipients, $mail->headers($this->_headers), $body);
     if (PEAR::isError($ret)) {
         throw new Gpf_Exception($ret->getMessage());
     }
     return true;
 }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:74,代码来源:Mail.class.php

示例8: array

                    $errstatus = false;
                    if ($mailerstatus) {
                        //Email Customization
                        $subject = "";
                        //Email Subject
                        $text = 'Wishes from University Health Centre';
                        //email Text
                        $subject = 'Birthday Wishes : Many more Happy Returns...';
                        //email headers
                        $headers = array('From' => $email_From, 'Subject' => $subject);
                        $crlf = "\r\n";
                        $mime = new Mail_mime($crlf);
                        //get mime mail object in order to set headers
                        $cid = "";
                        //content id for the images
                        $mime->addHTMLImage("../img/templates/email/bdemail12.jpg", "image/jpg");
                        //here's the butt-ugly bit where we grab the content id
                        $cid = $mime->_html_images[count($mime->_html_images) - 1]['cid'];
                        $html = '
						<html>
						<head>
						<title>Birthday wishes </title>
						</head>
						<body>
						<img src="cid:' . $cid . '" />
						</body>
						</html>
					';
                        //html content in order to Email students
                        $mime->setTXTBody($text);
                        $mime->setHTMLBody($html);
开发者ID:YogaViswaniKanduri,项目名称:AutomatedMailSenderApplication,代码行数:31,代码来源:automation_pages.php

示例9: send

 function send($to, $subject, $message, $options = null)
 {
     global $ost, $cfg;
     //Get the goodies
     require_once PEAR_DIR . 'Mail.php';
     // PEAR Mail package
     require_once PEAR_DIR . 'Mail/mime.php';
     // PEAR Mail_Mime packge
     //do some cleanup
     $to = preg_replace("/(\r\n|\r|\n)/s", '', trim($to));
     $subject = preg_replace("/(\r\n|\r|\n)/s", '', trim($subject));
     /* Message ID - generated for each outgoing email */
     $messageId = sprintf('<%s-%s-%s>', substr(md5('mail' . SECRET_SALT), -9), Misc::randCode(9), $this->getEmail() ? $this->getEmail()->getEmail() : '@osTicketMailer');
     $headers = array('From' => $this->getFromAddress(), 'To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Message-ID' => $messageId, 'X-Mailer' => 'osTicket Mailer');
     // Add in the options passed to the constructor
     $options = ($options ?: array()) + $this->options;
     if (isset($options['nobounce']) && $options['nobounce']) {
         $headers['Return-Path'] = '<>';
     } elseif ($this->getEmail() instanceof Email) {
         $headers['Return-Path'] = $this->getEmail()->getEmail();
     }
     //Bulk.
     if (isset($options['bulk']) && $options['bulk']) {
         $headers += array('Precedence' => 'bulk');
     }
     //Auto-reply - mark as autoreply and supress all auto-replies
     if (isset($options['autoreply']) && $options['autoreply']) {
         $headers += array('Precedence' => 'auto_reply', 'X-Autoreply' => 'yes', 'X-Auto-Response-Suppress' => 'DR, RN, OOF, AutoReply', 'Auto-Submitted' => 'auto-replied');
     }
     //Notice (sort of automated - but we don't want auto-replies back
     if (isset($options['notice']) && $options['notice']) {
         $headers += array('X-Auto-Response-Suppress' => 'OOF, AutoReply', 'Auto-Submitted' => 'auto-generated');
     }
     if ($options) {
         if (isset($options['inreplyto']) && $options['inreplyto']) {
             $headers += array('In-Reply-To' => $options['inreplyto']);
         }
         if (isset($options['references']) && $options['references']) {
             if (is_array($options['references'])) {
                 $headers += array('References' => implode(' ', $options['references']));
             } else {
                 $headers += array('References' => $options['references']);
             }
         }
     }
     // The Suhosin patch will muck up the line endings in some
     // cases
     //
     // References:
     // https://github.com/osTicket/osTicket-1.8/issues/202
     // http://pear.php.net/bugs/bug.php?id=12032
     // http://us2.php.net/manual/en/function.mail.php#97680
     if ((extension_loaded('suhosin') || defined("SUHOSIN_PATCH")) && !$this->getSMTPInfo()) {
         $mime = new Mail_mime("\n");
     } else {
         // Use defaults
         $mime = new Mail_mime();
     }
     // If the message is not explicitly declared to be a text message,
     // then assume that it needs html processing to create a valid text
     // body
     $isHtml = true;
     $mid_token = isset($options['thread']) ? $options['thread']->asMessageId($to) : '';
     if (!(isset($options['text']) && $options['text'])) {
         if ($cfg && $cfg->stripQuotedReply() && ($tag = $cfg->getReplySeparator()) && (!isset($options['reply-tag']) || $options['reply-tag'])) {
             $message = "<div style=\"display:none\"\n                    data-mid=\"{$mid_token}\">{$tag}<br/><br/></div>{$message}";
         }
         $txtbody = rtrim(Format::html2text($message, 90, false)) . ($mid_token ? "\nRef-Mid: {$mid_token}\n" : '');
         $mime->setTXTBody($txtbody);
     } else {
         $mime->setTXTBody($message);
         $isHtml = false;
     }
     if ($isHtml && $cfg && $cfg->isHtmlThreadEnabled()) {
         // Pick a domain compatible with pear Mail_Mime
         $matches = array();
         if (preg_match('#(@[0-9a-zA-Z\\-\\.]+)#', $this->getFromAddress(), $matches)) {
             $domain = $matches[1];
         } else {
             $domain = '@localhost';
         }
         // Format content-ids with the domain, and add the inline images
         // to the email attachment list
         $self = $this;
         $message = preg_replace_callback('/cid:([\\w.-]{32})/', function ($match) use($domain, $mime, $self) {
             if (!($file = AttachmentFile::lookup($match[1]))) {
                 return $match[0];
             }
             $mime->addHTMLImage($file->getData(), $file->getType(), $file->getName(), false, $match[1] . $domain);
             // Don't re-attach the image below
             unset($self->attachments[$file->getId()]);
             return $match[0] . $domain;
         }, $message);
         // Add an HTML body
         $mime->setHTMLBody($message);
     }
     //XXX: Attachments
     if ($attachments = $this->getAttachments()) {
         foreach ($attachments as $attachment) {
             if ($attachment['file_id'] && ($file = AttachmentFile::lookup($attachment['file_id']))) {
//.........这里部分代码省略.........
开发者ID:Jride,项目名称:OSTicket-Thaiconnections,代码行数:101,代码来源:class.mailer.php

示例10: _do_emaillearn

 private function _do_emaillearn($uids, $spam)
 {
     $rcmail = rcube::get_instance();
     $identity_arr = $rcmail->user->get_identity();
     $from = $identity_arr['email'];
     if ($spam) {
         $mailto = $rcmail->config->get('markasjunk2_email_spam');
     } else {
         $mailto = $rcmail->config->get('markasjunk2_email_ham');
     }
     $mailto = str_replace('%u', $_SESSION['username'], $mailto);
     $mailto = str_replace('%l', $rcmail->user->get_username('local'), $mailto);
     $mailto = str_replace('%d', $rcmail->user->get_username('domain'), $mailto);
     $mailto = str_replace('%i', $from, $mailto);
     if (!$mailto) {
         return;
     }
     $message_charset = $rcmail->output->get_charset();
     // chose transfer encoding
     $charset_7bit = array('ASCII', 'ISO-2022-JP', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-15');
     $transfer_encoding = in_array(strtoupper($message_charset), $charset_7bit) ? '7bit' : '8bit';
     $temp_dir = realpath($rcmail->config->get('temp_dir'));
     $subject = $rcmail->config->get('markasjunk2_email_subject');
     $subject = str_replace('%u', $_SESSION['username'], $subject);
     $subject = str_replace('%t', $spam ? 'spam' : 'ham', $subject);
     $subject = str_replace('%l', $rcmail->user->get_username('local'), $subject);
     $subject = str_replace('%d', $rcmail->user->get_username('domain'), $subject);
     // compose headers array
     $headers = array();
     $headers['Date'] = date('r');
     $headers['From'] = format_email_recipient($identity_arr['email'], $identity_arr['name']);
     $headers['To'] = $mailto;
     $headers['Subject'] = $subject;
     foreach ($uids as $uid) {
         $MESSAGE = new rcube_message($uid);
         // set message charset as default
         if (!empty($MESSAGE->headers->charset)) {
             $rcmail->storage->set_charset($MESSAGE->headers->charset);
         }
         $MAIL_MIME = new Mail_mime($rcmail->config->header_delimiter());
         if ($rcmail->config->get('markasjunk2_email_attach', false)) {
             $tmpPath = tempnam($temp_dir, 'rcmMarkASJunk2');
             // send mail as attachment
             $MAIL_MIME->setTXTBody(($spam ? 'Spam' : 'Ham') . ' report from ' . $rcmail->config->get('product_name'), false, true);
             $raw_message = $rcmail->storage->get_raw_body($uid);
             $subject = $MESSAGE->get_header('subject');
             if (isset($subject) && $subject != "") {
                 $disp_name = $subject . ".eml";
             } else {
                 $disp_name = "message_rfc822.eml";
             }
             if (file_put_contents($tmpPath, $raw_message)) {
                 $MAIL_MIME->addAttachment($tmpPath, "message/rfc822", $disp_name, true, $transfer_encoding, 'attachment', '', '', '', $rcmail->config->get('mime_param_folding') ? 'quoted-printable' : NULL, $rcmail->config->get('mime_param_folding') == 2 ? 'quoted-printable' : NULL, '', RCUBE_CHARSET);
             }
             // encoding settings for mail composing
             $MAIL_MIME->setParam('text_encoding', $transfer_encoding);
             $MAIL_MIME->setParam('html_encoding', 'quoted-printable');
             $MAIL_MIME->setParam('head_encoding', 'quoted-printable');
             $MAIL_MIME->setParam('head_charset', $message_charset);
             $MAIL_MIME->setParam('html_charset', $message_charset);
             $MAIL_MIME->setParam('text_charset', $message_charset);
             // pass headers to message object
             $MAIL_MIME->headers($headers);
         } else {
             $headers['Resent-From'] = $headers['From'];
             $headers['Resent-Date'] = $headers['Date'];
             $headers['Date'] = $MESSAGE->headers->date;
             $headers['From'] = $MESSAGE->headers->from;
             $headers['Subject'] = $MESSAGE->headers->subject;
             $MAIL_MIME->headers($headers);
             if ($MESSAGE->has_html_part()) {
                 $body = $MESSAGE->first_html_part();
                 $MAIL_MIME->setHTMLBody($body);
             }
             $body = $MESSAGE->first_text_part();
             $MAIL_MIME->setTXTBody($body, false, true);
             foreach ($MESSAGE->attachments as $attachment) {
                 $MAIL_MIME->addAttachment($MESSAGE->get_part_body($attachment->mime_id, true), $attachment->mimetype, $attachment->filename, false, $attachment->encoding, $attachment->disposition, '', $attachment->charset);
             }
             foreach ($MESSAGE->mime_parts as $attachment) {
                 if (!empty($attachment->content_id)) {
                     // covert CID to Mail_MIME format
                     $attachment->content_id = str_replace('<', '', $attachment->content_id);
                     $attachment->content_id = str_replace('>', '', $attachment->content_id);
                     if (empty($attachment->filename)) {
                         $attachment->filename = $attachment->content_id;
                     }
                     $message_body = $MAIL_MIME->getHTMLBody();
                     $dispurl = 'cid:' . $attachment->content_id;
                     $message_body = str_replace($dispurl, $attachment->filename, $message_body);
                     $MAIL_MIME->setHTMLBody($message_body);
                     $MAIL_MIME->addHTMLImage($MESSAGE->get_part_body($attachment->mime_id, true), $attachment->mimetype, $attachment->filename, false);
                 }
             }
             // encoding settings for mail composing
             $MAIL_MIME->setParam('head_encoding', $MESSAGE->headers->encoding);
             $MAIL_MIME->setParam('head_charset', $MESSAGE->headers->charset);
             foreach ($MESSAGE->mime_parts as $mime_id => $part) {
                 $mimetype = strtolower($part->ctype_primary . '/' . $part->ctype_secondary);
                 if ($mimetype == 'text/html') {
//.........这里部分代码省略.........
开发者ID:aalmenar,项目名称:Roundcube-Plugin-Mark-as-Junk-2,代码行数:101,代码来源:email_learn.php

示例11: vendorsClass

    $vendor = $vpc->findVendorWithEmail($username);
    if (!is_null($vendor)) {
        $isAdmin = $vendor->isAdmin();
    }
}
if ($isAdmin) {
    include_once 'vendorsClass.php';
    include_once 'Mail.php';
    require_once '/home/dvaqpvvw/php/Mail/mime.php';
    $vC = new vendorsClass();
    $admins = $vC->getAdmins();
    $vendor = $vC->getVendorByID($_REQUEST['vendorID']);
    $crlf = "\r\n";
    $hdrs = array('From' => 'noreply@stlbridalpros.com', 'Subject' => 'Welcome to St. Louis Bridal Professionals');
    $mime = new Mail_mime($crlf);
    $mime->addHTMLImage("images/stlbridalprosLogo_200x180.jpg", "image/jpeg");
    $logo_cid = $mime->_html_images[count($mime->_html_images) - 1]['cid'];
    $mime->addHTMLImage("images/adminLogin.gif", "image/gif");
    $loginButton_cid = $mime->_html_images[count($mime->_html_images) - 1]['cid'];
    $emailBody = "<p>Welcome to <b>St. Louis Bridal Professionals</b>!</p>";
    $emailBody .= "<p> A profile has been created for you, but you must fill in the information before your information will be made available on the website.</p>";
    $emailBody .= '<p><a href="http://www.stlbridalpros.com/vendorLogin.php">Click here login and finish your profile.</a></p>';
    $emailBody .= '<p>Keep your login details for reference:</p>';
    $emailBody .= '<p><b>Email: </b>' . $vendor->email . '</p>';
    $emailBody .= '<p><b>Password: </b>' . $vendor->password . '</p>';
    $emailBody .= '<p>You can login from the main website (<a href="http://www.stlbridalpros.com">www.stlbridalpros.com</a>) by clicking this image: <img id="loginButton" src="cid:' . $loginButton_cid . '"/> found at the bottom of the page.</p>';
    $emailBody .= '<br/><br/><p>We look forward to having you be a part of this group!</p>';
    $emailBody .= '<p>If you have problems contact: ';
    $adminCount = 0;
    $adminContactMsg = "";
    foreach ($admins as $admin) {
开发者ID:ctwoolsey,项目名称:stlbproWebsite_git,代码行数:31,代码来源:sendWelcomeEmail.php

示例12: correo

 function correo($to, $subject, $body, $tipo = 'txt', $adjuntos = array(), $embededimage = array())
 {
     $CI =& get_instance();
     if (!@(include_once 'Mail.php')) {
         $error = 'Problemas al cargar la clase Mail, probablemente sea necesario instalarla desde PEAR, comuniquese con soporte t&eacute;cnico';
         return false;
     }
     if (!@(include_once 'Mail/mime.php')) {
         $error = 'Problemas al cargar la clase Mail_mime, probablemente sea necesario instalarla desde PEAR, comuniquese con soporte t&eacute;cnico';
         return false;
     }
     $CI->config->load('notifica');
     $message = new Mail_mime();
     $from = $CI->config->item('mail_smtp_from');
     $host = $CI->config->item('mail_smtp_host');
     $port = $CI->config->item('mail_smtp_port');
     $user = $CI->config->item('mail_smtp_usr');
     $pass = $CI->config->item('mail_smtp_pwd');
     $extraheaders = array('From' => $from, 'To' => $to, 'Subject' => $subject);
     if (count($embededimage) > 0) {
         foreach ($embededimage as $adj) {
             $message->addHTMLImage($adj[0], $adj[1], $adj[2], $adj[3], $adj[4]);
         }
     }
     if (is_array($adjuntos)) {
         foreach ($adjuntos as $adj) {
             $message->addAttachment($adj);
         }
     }
     $parr = array('host' => $host, 'port' => $port, 'auth' => true, 'username' => $user, 'password' => $pass);
     if ($tipo == 'html') {
         $hbody = '<html><head><title></title>';
         $hbody .= '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
         $hbody .= '</head>';
         $hbody .= '<body>';
         $hbody .= $body;
         $hbody .= '</body></html>';
         $message->setHTMLBody($hbody);
     } else {
         $message->setTXTBody($body);
     }
     $sbody = $message->get();
     $headers = $message->headers($extraheaders);
     $smtp = Mail::factory('smtp', $parr);
     $mail = $smtp->send($to, $headers, $sbody);
     if (PEAR::isError($mail)) {
         $CI->error = $mail->getMessage();
         return false;
     } else {
         return true;
     }
 }
开发者ID:codethics,项目名称:proteoerp,代码行数:52,代码来源:Datasis.php

示例13: send


//.........这里部分代码省略.........
         if ($irt = $options['thread']->getEmailMessageId()) {
             // This is an response from an email, like and autoresponse.
             // Web posts will not have a email message-id
             $headers += array('In-Reply-To' => $irt, 'References' => $options['thread']->getEmailReferences());
         } elseif ($parent = $options['thread']->getParent()) {
             // Use the parent item as the email information source. This
             // will apply for staff replies
             $headers += array('In-Reply-To' => $parent->getEmailMessageId(), 'References' => $parent->getEmailReferences());
         }
         // Configure the reply tag and embedded message id token
         $mid_token = $options['thread']->asMessageId($to);
         if ($cfg && $cfg->stripQuotedReply() && (!isset($options['reply-tag']) || $options['reply-tag'])) {
             $reply_tag = $cfg->getReplySeparator() . '<br/><br/>';
         }
     }
     // Use general failsafe default initially
     $eol = "\n";
     // MAIL_EOL setting can be defined in `ost-config.php`
     if (defined('MAIL_EOL') && is_string(MAIL_EOL)) {
         $eol = MAIL_EOL;
     }
     $mime = new Mail_mime($eol);
     // If the message is not explicitly declared to be a text message,
     // then assume that it needs html processing to create a valid text
     // body
     $isHtml = true;
     if (!(isset($options['text']) && $options['text'])) {
         if ($reply_tag || $mid_token) {
             $message = "<div style=\"display:none\"\n                    class=\"mid-{$mid_token}\">{$reply_tag}</div>{$message}";
         }
         $txtbody = rtrim(Format::html2text($message, 90, false)) . ($mid_token ? "\nRef-Mid: {$mid_token}\n" : '');
         $mime->setTXTBody($txtbody);
     } else {
         $mime->setTXTBody($message);
         $isHtml = false;
     }
     if ($isHtml && $cfg && $cfg->isHtmlThreadEnabled()) {
         // Pick a domain compatible with pear Mail_Mime
         $matches = array();
         if (preg_match('#(@[0-9a-zA-Z\\-\\.]+)#', $this->getFromAddress(), $matches)) {
             $domain = $matches[1];
         } else {
             $domain = '@localhost';
         }
         // Format content-ids with the domain, and add the inline images
         // to the email attachment list
         $self = $this;
         $message = preg_replace_callback('/cid:([\\w.-]{32})/', function ($match) use($domain, $mime, $self) {
             if (!($file = AttachmentFile::lookup($match[1]))) {
                 return $match[0];
             }
             $mime->addHTMLImage($file->getData(), $file->getType(), $file->getName(), false, $match[1] . $domain);
             // Don't re-attach the image below
             unset($self->attachments[$file->getId()]);
             return $match[0] . $domain;
         }, $message);
         // Add an HTML body
         $mime->setHTMLBody($message);
     }
     //XXX: Attachments
     if ($attachments = $this->getAttachments()) {
         foreach ($attachments as $attachment) {
             if ($attachment['file_id'] && ($file = AttachmentFile::lookup($attachment['file_id']))) {
                 $mime->addAttachment($file->getData(), $file->getType(), $file->getName(), false);
             }
         }
     }
     //Desired encodings...
     $encodings = array('head_encoding' => 'quoted-printable', 'text_encoding' => 'base64', 'html_encoding' => 'base64', 'html_charset' => 'utf-8', 'text_charset' => 'utf-8', 'head_charset' => 'utf-8');
     //encode the body
     $body = $mime->get($encodings);
     //encode the headers.
     $headers = $mime->headers($headers, true);
     // Cache smtp connections made during this request
     static $smtp_connections = array();
     if ($smtp = $this->getSMTPInfo()) {
         //Send via SMTP
         $key = sprintf("%s:%s:%s", $smtp['host'], $smtp['port'], $smtp['username']);
         if (!isset($smtp_connections[$key])) {
             $mail = mail::factory('smtp', array('host' => $smtp['host'], 'port' => $smtp['port'], 'auth' => $smtp['auth'], 'username' => $smtp['username'], 'password' => $smtp['password'], 'timeout' => 20, 'debug' => false, 'persist' => true));
             if ($mail->connect()) {
                 $smtp_connections[$key] = $mail;
             }
         } else {
             // Use persistent connection
             $mail = $smtp_connections[$key];
         }
         $result = $mail->send($to, $headers, $body);
         if (!PEAR::isError($result)) {
             return $messageId;
         }
         // Force reconnect on next ->send()
         unset($smtp_connections[$key]);
         $alert = sprintf(__("Unable to email via SMTP:%1\$s:%2\$d [%3\$s]\n\n%4\$s\n"), $smtp['host'], $smtp['port'], $smtp['username'], $result->getMessage());
         $this->logError($alert);
     }
     //No SMTP or it failed....use php's native mail function.
     $mail = mail::factory('mail');
     return PEAR::isError($mail->send($to, $headers, $body)) ? false : $messageId;
 }
开发者ID:KM-MFG,项目名称:osTicket-1.8,代码行数:101,代码来源:class.mailer.php

示例14: send_email

/**
 * TAG_TODO: написать очень, очень подробный комментарий сюда
 *
 */
function send_email($mailer, $from, $to, $subject, $body, $headers = array(), $attachments = array(), $server_params = null)
{
    logthis('[send_email] : sending email "' . $subject . '" from "' . $from . '" to "' . $to . '"');
    // extract emails
    if (!preg_match('~[a-zA-Z0-9.\\-]+@[a-zA-Z0-9.\\-]+~', $to, $mail_addresses)) {
        logthis('[send_email] : no addresses found!', ZLogger::LOG_LEVEL_ERROR);
        return false;
    }
    // $to may contain such structure: Julia (julia@example.com). Round brackets should be replaced with angle brackets
    $to = preg_replace('~[\\<\\[\\(]*([a-zA-Z0-9.\\-]+@[a-zA-Z0-9.\\-]+)[\\>\\]\\)]*~', '<$1>', $to);
    // encoding data for mail_mime
    $encoding_parameters = array('head_encoding' => 'base64', 'text_encoding' => 'base64', 'html_encoding' => 'base64', 'head_charset' => 'utf-8', 'text_charset' => 'utf-8', 'html_charset' => 'utf-8');
    // add some important headers
    $headers_primary = array('From' => $from, 'To' => $to, 'Subject' => $subject);
    $headers = array_merge($headers_primary, $headers);
    // create mail body generator
    $mime = new Mail_mime($encoding_parameters);
    // by default, no text part
    $mime->setTXTBody('');
    $alarm = 0;
    // replace image links with attached images
    if ($image_count = preg_match_all('~<img[^>]+src="(?!cid:)([^"]+)"[^>]*>~', $body, $img_data)) {
        for ($img_index = 0; $img_index < $image_count; $img_index++) {
            // generate new CID
            $cid = strtolower(str_replace('-', '', create_guid()));
            // image full CID, must contain sender domain to be displayed inline instead as attachment
            $cid_full = $cid . '@' . preg_replace('~[^@]*@~', '', $from);
            // add image
            $mime->addHTMLImage($img_data[1][$img_index], get_file_mime_type($img_data[1][$img_index]), '', true, $cid);
            // replace local image link to inline
            $new_image_link = str_replace($img_data[1][$img_index], 'cid:' . $cid_full, $img_data[0][$img_index]);
            // new image link
            $body = str_replace($img_data[0][$img_index], $new_image_link, $body);
        }
    }
    // ok, HTML part is ready now
    $mime->setHTMLBody($body);
    // add attachments
    foreach ($attachments as $attachment) {
        $attachment_filename = $attachment['filename'];
        $attachment_realname = $attachment['realname'];
        $mime->addAttachment($attachment_filename, get_file_mime_type($attachment_filename), $attachment_realname, true, 'base64', 'attachment', '', '', '', 'base64', 'utf-8', '', 'utf-8');
    }
    // generate final headers
    $headers_ready = $mime->headers($headers);
    // get full message body
    $body_ready = $mime->get();
    // now send
    $mail_result = $mailer->send($mail_addresses, $headers_ready, $body_ready);
    // free mem as messages are big
    unset($mime);
    // log result
    if ($mail_result === true) {
        logthis('[send_email] : ok');
    } else {
        logthis('[send_email] : failed mailing to ' . $to . ' : ' . $mail_result->getMessage(), ZLogger::LOG_LEVEL_ERROR);
    }
    return $mail_result;
}
开发者ID:kzotoff,项目名称:JuliaCMS,代码行数:63,代码来源:common.php

示例15: toData

 /**
  * ---------------- Global Tools ---------------   
  */
 function toData()
 {
     $templateFile = $this->template;
     $args = (array) $this->contents;
     $content = clone $this->page;
     foreach ($args as $k => $v) {
         $content->{$k} = $v;
     }
     $content->msgid = empty($content->msgid) ? md5(time() . rand()) : $content->msgid;
     $ff = HTML_FlexyFramework::get();
     $http_host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : 'pman.HTTP_HOST.not.set';
     if (isset($ff->Pman['HTTP_HOST'])) {
         $http_host = $ff->Pman['HTTP_HOST'];
     }
     $content->HTTP_HOST = $http_host;
     // this should be done by having multiple template sources...!!!
     require_once 'HTML/Template/Flexy.php';
     $tmp_opts = array('site_prefix' => false);
     if (!empty($this->templateDir)) {
         $tmp_opts['templateDir'] = $this->templateDir;
     }
     $fopts = HTML_FlexyFramework::get()->HTML_Template_Flexy;
     if (!empty($fopts['DB_DataObject_translator'])) {
         $tmp_opts['DB_DataObject_translator'] = $fopts['DB_DataObject_translator'];
     }
     if (!empty($fopts['locale'])) {
         $tmp_opts['locale'] = $fopts['locale'];
     }
     // local opt's overwrite
     if (!empty($this->locale)) {
         $tmp_opts['locale'] = $this->locale;
     }
     $htmlbody = false;
     $html_tmp_opts = $tmp_opts;
     $htmltemplate = new HTML_Template_Flexy($html_tmp_opts);
     if (is_string($htmltemplate->resolvePath('mail/' . $templateFile . '.body.html'))) {
         // then we have a multi-part email...
         if (!empty($this->html_locale)) {
             $html_tmp_opts['locale'] = $this->html_locale;
         }
         $htmltemplate = new HTML_Template_Flexy($html_tmp_opts);
         $htmltemplate->compile('mail/' . $templateFile . '.body.html');
         $htmlbody = $htmltemplate->bufferedOutputObject($content);
         $this->htmlbody = $htmlbody;
         // for the html body, we may want to convert the attachments to images.
         //            var_dump($htmlbody);exit;
         if ($this->replaceImages) {
             $htmlbody = $this->htmlbodytoCID($htmlbody);
         }
         if ($this->css_embed) {
             $htmlbody = $this->htmlbodyCssEmbed($htmlbody);
         }
     }
     $tmp_opts['nonHTML'] = true;
     //print_R($tmp_opts);
     // $tmp_opts['force'] = true;
     $template = new HTML_Template_Flexy($tmp_opts);
     $template->compile('mail/' . $templateFile . '.txt');
     /* use variables from this object to ouput data. */
     $mailtext = $template->bufferedOutputObject($content);
     //print_r($mailtext);exit;
     //echo "<PRE>";print_R($mailtext);
     /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */
     require_once 'Mail/mimeDecode.php';
     require_once 'Mail.php';
     $decoder = new Mail_mimeDecode($mailtext);
     $parts = $decoder->getSendArray();
     if (PEAR::isError($parts)) {
         return $parts;
         //echo "PROBLEM: {$parts->message}";
         //exit;
     }
     $isMime = false;
     require_once 'Mail/mime.php';
     $mime = new Mail_mime(array('eol' => "\n", 'html_charset' => 'utf-8', 'text_charset' => 'utf-8', 'head_charset' => 'utf-8'));
     // clean up the headers...
     $parts[1]['Message-Id'] = '<' . $content->msgid . '@' . $content->HTTP_HOST . '>';
     if ($htmlbody !== false) {
         // got a html headers...
         if (isset($parts[1]['Content-Type'])) {
             unset($parts[1]['Content-Type']);
         }
         $mime->setTXTBody($parts[2]);
         $mime->setHTMLBody($htmlbody);
         //            var_dump($mime);exit;
         foreach ($this->images as $cid => $cdata) {
             $mime->addHTMLImage($cdata['file'], $cdata['mimetype'], $cid . '.' . $cdata['ext'], true, $cdata['contentid']);
         }
         $isMime = true;
     }
     if (!empty($this->attachments)) {
         //if got a attachments
         $header = $mime->headers($parts[1]);
         if (isset($parts[1]['Content-Type'])) {
             unset($parts[1]['Content-Type']);
         }
         if (!$isMime) {
//.........这里部分代码省略.........
开发者ID:roojs,项目名称:Pman.Core,代码行数:101,代码来源:Mailer.php


注:本文中的Mail_mime::addHTMLImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。