• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mb_decode_mimeheader函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中mb_decode_mimeheader函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_decode_mimeheader函数的具体用法?PHP mb_decode_mimeheader怎么用?PHP mb_decode_mimeheader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: send

 /**
  * Sends out email via Mandrill
  *
  * @param CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $from = $this->_cakeEmail->from();
     list($fromEmail) = array_keys($from);
     $fromName = $from[$fromEmail];
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders();
     $message = array('html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'from_email' => $fromEmail, 'from_name' => $fromName, 'to' => array(), 'headers' => array('Reply-To' => $fromEmail), 'important' => false, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true, 'tags' => null, 'subaccount' => null);
     $message = array_merge($message, $this->_headers);
     foreach ($this->_cakeEmail->to() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'to');
     }
     foreach ($this->_cakeEmail->cc() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'cc');
     }
     foreach ($this->_cakeEmail->bcc() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'bcc');
     }
     $attachments = $this->_cakeEmail->attachments();
     if (!empty($attachments)) {
         $message['attachments'] = array();
         foreach ($attachments as $file => $data) {
             $message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'content' => base64_encode(file_get_contents($data['file'])));
         }
     }
     $params = array('message' => $message, "async" => false, "ip_pool" => null, "send_at" => null);
     return $this->_exec($params);
 }
开发者ID:surjit,项目名称:Mandrill-CakePHP-plugin,代码行数:36,代码来源:MandrillTransport.php


示例2: send

 /**
  * Send mail using Mandrill (by MailChimp)
  *
  * @param \Cake\Network\Email\Email $email Cake Email
  * @return array
  */
 public function send(\Cake\Network\Email\Email $email)
 {
     $this->transportConfig = Hash::merge($this->transportConfig, $this->_config);
     // Initiate a new Mandrill Message parameter array
     $message = ['html' => $email->message(\Cake\Network\Email\Email::MESSAGE_HTML), 'text' => $email->message(\Cake\Network\Email\Email::MESSAGE_TEXT), 'subject' => mb_decode_mimeheader($email->subject()), 'from_email' => key($email->from()), 'from_name' => current($email->from()), 'to' => [], 'headers' => ['Reply-To' => key($email->from())], 'recipient_metadata' => [], 'attachments' => [], 'images' => []];
     // Merge Mandrill Parameters
     $message = array_merge($message, Hash::merge($this->defaultParameters, $email->profile()['Mandrill']));
     // Format attachments
     $message = $this->_attachments($email, $message);
     // Format recipients
     $message = $this->_recipients($email, $message);
     // Create a new scoped Http Client
     $this->http = new Client(['host' => 'mandrillapp.com', 'scheme' => 'https', 'headers' => ['User-Agent' => 'CakePHP Mandrill Plugin']]);
     // Sending as a template? Then in case we find mail content, we add this as a 'template_content'.
     // In you Mandrill template, use <div mc:edit="content"></div> to get the contents of your email
     if (!is_null($message['template_name']) && $message['html']) {
         if (!isset($message['template_content']) || !is_array($message['template_content'])) {
             $message['template_content'] = [];
         }
         $message['template_content'][] = ['name' => 'content', 'content' => $message['html']];
     }
     // Are we sending a template?
     if (!is_null($message['template_name']) && !empty($message['template_content'])) {
         return $this->_sendTemplate($message, $this->transportConfig['async'], $this->transportConfig['ip_pool'], $message['send_at']);
     } else {
         return $this->_send($message, $this->transportConfig['async'], $this->transportConfig['ip_pool'], $message['send_at']);
     }
 }
开发者ID:damianoporta,项目名称:cakephp-mandrill,代码行数:34,代码来源:MandrillTransport.php


示例3: send

 /**
  * Sends out email via SparkPost
  *
  * @param CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders();
     // Not allowed by SparkPost
     unset($this->_headers['Content-Type']);
     unset($this->_headers['Content-Transfer-Encoding']);
     unset($this->_headers['MIME-Version']);
     unset($this->_headers['X-Mailer']);
     $from = $this->_cakeEmail->from();
     list($fromEmail) = array_keys($from);
     $fromName = $from[$fromEmail];
     $message = ['html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'from' => ['name' => $fromName, 'email' => $fromEmail], 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'recipients' => [], 'transactional' => true];
     foreach ($this->_cakeEmail->to() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     foreach ($this->_cakeEmail->cc() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     foreach ($this->_cakeEmail->bcc() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     unset($this->_headers['tags']);
     $attachments = $this->_cakeEmail->attachments();
     if (!empty($attachments)) {
         $message['attachments'] = array();
         foreach ($attachments as $file => $data) {
             if (!empty($data['contentId'])) {
                 $message['inlineImages'][] = array('type' => $data['mimetype'], 'name' => $data['contentId'], 'data' => base64_encode(file_get_contents($data['file'])));
             } else {
                 $message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'data' => base64_encode(file_get_contents($data['file'])));
             }
         }
     }
     $message = array_merge($message, $this->_headers);
     // Load SparkPost configuration settings
     $config = ['key' => $this->_config['sparkpost']['api_key']];
     if (isset($this->_config['sparkpost']['timeout'])) {
         $config['timeout'] = $this->_config['sparkpost']['timeout'];
     }
     // Set up HTTP request adapter
     $httpAdapter = new Ivory\HttpAdapter\Guzzle6HttpAdapter($this->__getClient());
     // Create SparkPost API accessor
     $sparkpost = new SparkPost\SparkPost($httpAdapter, $config);
     // Send message
     try {
         return $sparkpost->transmission->send($message);
     } catch (SparkPost\APIResponseException $e) {
         // TODO: Determine if BRE is the best exception type
         throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)', $e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
     }
 }
开发者ID:wvdongen,项目名称:cakephp-sparkpost,代码行数:60,代码来源:SparkPostTransport.php


示例4: getHeader

 public function getHeader($name, $format = null)
 {
     $result = parent::getHeader($name, $format);
     if ('array' !== $format && function_exists('mb_decode_mimeheader')) {
         $result = mb_decode_mimeheader($result);
     }
     if ('from' === strtolower($name) || 'to' === strtolower($name)) {
         $result = $this->extractAddrSpec($result);
     }
     return $result;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:11,代码来源:opMailMessage.class.php


示例5: convert_mail_str

 function convert_mail_str($str, $to = "", $from = "")
 {
     $str = mb_decode_mimeheader($str);
     if ($to != "" && $from != "") {
         $str = mb_convert_encoding($str, $to, $from);
     } else {
         if ($to != "") {
             $str = mb_convert_encoding($str, $to, "auto");
         }
     }
     return $str;
 }
开发者ID:ateliee,项目名称:php_lib,代码行数:12,代码来源:class_imap.php


示例6: send

 /**
  * Send mail
  *
  * @param \Cake\Mailer\Email $email Email instance.
  * @return array
  */
 public function send(Email $email)
 {
     $this->transportConfig = Hash::merge($this->transportConfig, $this->_config);
     $message = ['html' => $email->message(Email::MESSAGE_HTML), 'text' => $email->message(Email::MESSAGE_TEXT), 'subject' => mb_decode_mimeheader($email->subject()), 'from' => key($email->from()), 'fromname' => current($email->from()), 'to' => [], 'toname' => [], 'cc' => [], 'ccname' => [], 'bcc' => [], 'bccname' => [], 'replyto' => array_keys($email->replyTo())[0]];
     // Add receipients
     foreach (['to', 'cc', 'bcc'] as $type) {
         foreach ($email->{$type}() as $mail => $name) {
             $message[$type][] = $mail;
             $message[$type . 'name'][] = $name;
         }
     }
     // Create a new scoped Http Client
     $this->http = new Client(['host' => 'api.sendgrid.com', 'scheme' => 'https', 'headers' => ['User-Agent' => 'CakePHP SendGrid Plugin']]);
     $message = $this->_attachments($email, $message);
     return $this->_send($message);
 }
开发者ID:iandenh,项目名称:cakephp-sendgrid,代码行数:22,代码来源:SendgridTransport.php


示例7: process

 /**
  * Parse attachments from message mimeparts.
  */
 function process(&$message, $source)
 {
     $message['attachments'] = array();
     foreach ($message['mimeparts'] as $attachment) {
         // 'unnamed_attachment' files are not really attachments, but mimeparts like HTML or Plain Text.
         // We only want to save real attachments, like images and files.
         if ($attachment->filename !== 'unnamed_attachment') {
             $destination = 'temporary://';
             $filename = mb_decode_mimeheader($attachment->filename);
             $file = file_save_data($attachment->data, $destination . $filename);
             $file->status = 0;
             drupal_write_record('file_managed', $file, 'fid');
             $message['attachments'][] = new FeedsEnclosure($file->uri, $attachment->filemime);
         }
     }
     unset($message['mimeparts']);
 }
开发者ID:tierce,项目名称:ppbe,代码行数:20,代码来源:MailhandlerCommandsFiles.class.php


示例8: read

 private function read()
 {
     $allMails = imap_search($this->conn, 'ALL');
     if ($allMails) {
         rsort($allMails);
         foreach ($allMails as $email_number) {
             $overview = imap_fetch_overview($this->conn, $email_number, 0);
             $structure = imap_fetchstructure($this->conn, $email_number);
             $body = '';
             if (isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) {
                 $part = $structure->parts[1];
                 $body = imap_fetchbody($this->conn, $email_number, 2);
                 if ($part->encoding == 3) {
                     $body = imap_base64($body);
                 } else {
                     if ($part->encoding == 1) {
                         $body = imap_8bit($body);
                     } else {
                         $body = imap_qprint($body);
                     }
                 }
             }
             $body = utf8_decode($body);
             $fromaddress = utf8_decode(imap_utf7_encode($overview[0]->from));
             $subject = mb_decode_mimeheader($overview[0]->subject);
             $date = utf8_decode(imap_utf8($overview[0]->date));
             $date = date('Y-m-d H:i:s', strtotime($date));
             $key = md5($fromaddress . $subject . $body);
             //save to MySQL
             $sql = "SELECT count(*) FROM EMAIL_INFORMATION WHERE IDMAIL = " . $this->id . " AND CHECKVERS = \"" . $key . "\"";
             $resul = $this->pdo->query($sql)->fetch();
             if ($resul[0] == 0) {
                 $this->pdo->prepare("INSERT INTO EMAIL_INFORMATION (IDMAIL,FROMADDRESS,SUBJECT,DATE,BODY,CHECKVERS) VALUES (?,?,?,?,?,?)");
                 $this->pdo->execute(array($this->id, $fromaddress, $subject, $date, $body, $key));
             }
         }
     }
 }
开发者ID:GPierre-Antoine,项目名称:projetphp,代码行数:38,代码来源:Email.php


示例9: process

 /**
  * Parse attachments from message mimeparts.
  */
 public function process(&$message, $source)
 {
     $message['attachments'] = array();
     foreach ($message['mimeparts'] as $attachment) {
         // 'unnamed_attachment' files are not really attachments, but mimeparts like HTML or Plain Text.
         // We only want to save real attachments, like images and files.
         if ($attachment->filename !== 'unnamed_attachment') {
             $destination = 'public://mailhandler_temp/';
             file_prepare_directory($destination, FILE_CREATE_DIRECTORY);
             $filename = mb_decode_mimeheader($attachment->filename);
             $file = file_save_data($attachment->data, $destination . $filename);
             $file->status = 0;
             drupal_write_record('file_managed', $file, 'fid');
             if (!empty($attachment->id)) {
                 $cid = trim($attachment->id, '<>');
                 $uri = 'cid:' . $cid;
                 $message['body_html'] = str_replace($uri, $file->uri, $message['body_html']);
             }
             $message['attachments'][] = new FeedsEnclosure($file->uri, $attachment->filemime);
         }
     }
     unset($message['mimeparts']);
 }
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:26,代码来源:MailhandlerCommandsFiles.class.php


示例10: send

 /**
  * Send mail via SparkPost REST API
  *
  * @param \Cake\Mailer\Email $email Email message
  * @return array
  */
 public function send(Email $email)
 {
     // Load SparkPost configuration settings
     $apiKey = $this->config('apiKey');
     // Set up HTTP request adapter
     $adapter = new CakeHttpAdapter(new Client());
     // Create SparkPost API accessor
     $sparkpost = new SparkPost($adapter, ['key' => $apiKey]);
     // Pre-process CakePHP email object fields
     $from = (array) $email->from();
     $sender = sprintf('%s <%s>', mb_encode_mimeheader(array_values($from)[0]), array_keys($from)[0]);
     $to = (array) $email->to();
     $recipients = [['address' => ['name' => mb_encode_mimeheader(array_values($to)[0]), 'email' => array_keys($to)[0]]]];
     // Build message to send
     $message = ['from' => $sender, 'html' => empty($email->message('html')) ? $email->message('text') : $email->message('html'), 'text' => $email->message('text'), 'subject' => mb_decode_mimeheader($email->subject()), 'recipients' => $recipients];
     // Send message
     try {
         $sparkpost->transmission->send($message);
     } catch (APIResponseException $e) {
         // TODO: Determine if BRE is the best exception type
         throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)', $e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
     }
 }
开发者ID:syntaxera,项目名称:cakephp-sparkpost-plugin,代码行数:29,代码来源:SparkPostTransport.php


示例11: decodeHeader

function decodeHeader($header)
{
    return mb_decode_mimeheader($header);
}
开发者ID:hackathonUTC,项目名称:billetterie-utc,代码行数:4,代码来源:mailclass.php


示例12: _decode

 /**
  * Decode the specified string using the current charset
  *
  * @param string $text String to decode
  * @return string Decoded string
  */
 protected function _decode($text)
 {
     $restore = mb_internal_encoding();
     mb_internal_encoding(Configure::read('App.encoding'));
     $return = mb_decode_mimeheader($text);
     mb_internal_encoding($restore);
     return $return;
 }
开发者ID:lennaert,项目名称:cakephp3-mandrill,代码行数:14,代码来源:MandrillTransport.php


示例13: __toString

// define some classes
class classWithToString
{
    public function __toString()
    {
        return "Class A object";
    }
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -2345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float 12.3456789000e10' => 123456789000.0, 'float -12.3456789000e10' => -123456789000.0, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $fp);
// loop through each element of the array for string
foreach ($inputs as $key => $value) {
    echo "\n--{$key}--\n";
    var_dump(mb_decode_mimeheader($value));
}
fclose($fp);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:mb_decode_mimeheader_variation1.php


示例14: trim

 $content = trim($content);
 //Please uncomment following line, only if you want to check user and password.
 //		echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>";
 #Check to see if there is an attachment, if there is, save the filename in the temp directory
 #First define some constants and message types
 $type = array("text", "multipart", "message", "application", "audio", "image", "video", "other");
 #message encodings
 $encoding = array("7bit", "8bit", "binary", "base64", "quoted-printable", "other");
 #parse message body (not really used yet, will be used for multiple attachments)
 $attach = parse($struct);
 $attach_parts = get_attachments($attach);
 #get the attachment
 $attachment = imap_fetchbody($mbox, $iCount, 2);
 if ($attachment != '') {
     $attachment = imap_base64($attachment);
     $temp_file = mb_convert_encoding(mb_decode_mimeheader($struct->parts[1]->dparameters[0]->value), $blog_charset, "auto");
     echo $temp_file;
     if (!($temp_fp = fopen("attach/" . $temp_file, "w"))) {
         echo "error1";
         continue;
     }
     fputs($temp_fp, $attachment);
     fclose($temp_fp);
     wp_create_thumbnail("attach/" . $temp_file, 160, "");
 } else {
     $attachment = false;
 }
 if ($xooptDB) {
     $sql = "SELECT ID, user_level FROM {$tableusers} WHERE user_login='{$user_login}' ORDER BY ID DESC LIMIT 1";
     $result = $wpdb->get_row($sql);
     if (!$result) {
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:31,代码来源:wp-moblog.php


示例15: renderSubject

 function renderSubject(MailQueue $m)
 {
     $s = $m->subject;
     if (strpos($s, '=?') === 0) {
         $s = mb_decode_mimeheader($s);
     }
     return "<td>" . Am_Controller::escape($s) . "</td>";
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:8,代码来源:AdminLogsController.php


示例16: decodeHeader

 /**
  * @param string|array $value
  * @return string
  */
 protected function decodeHeader($value)
 {
     if (is_array($value)) {
         foreach ($value as &$v) {
             $v = $this->decodeHeader($v);
         }
         unset($v);
         return $value;
     }
     if (preg_match("/=\\?(.+)\\?(B|Q)\\?(.*)\\?=?(.*)/i", $value, $m)) {
         $value = ltrim($value);
         if (isset($m[3]) && strpos($m[3], '_') !== false && strpos($m[3], ' ') === false) {
             $value = iconv_mime_decode(str_replace("\n", "", $value), 0, 'UTF-8');
         } else {
             $temp = mb_decode_mimeheader($value);
             if ($temp === $value) {
                 $value = iconv_mime_decode($value, 0, 'UTF-8');
             } else {
                 $value = $temp;
             }
         }
     } elseif (isset($this->part['params']['charset'])) {
         $value = @iconv($this->part['params']['charset'], 'UTF-8', $value);
     }
     if (!preg_match('//u', $value)) {
         $charset = mb_detect_encoding($value);
         if ($charset && ($temp = iconv($charset, 'UTF-8', $value))) {
             $value = $temp;
         }
     }
     return $value;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:36,代码来源:waMailDecode.class.php


示例17: processIncomingEmailAccount

 public function processIncomingEmailAccount(IncomingEmailAccount $account)
 {
     $count = 0;
     if ($emails = $account->getUnprocessedEmails()) {
         try {
             $current_user = framework\Context::getUser();
             foreach ($emails as $email) {
                 $user = $this->getOrCreateUserFromEmailString($email->from);
                 if ($user instanceof User) {
                     if (framework\Context::getUser()->getID() != $user->getID()) {
                         framework\Context::switchUserContext($user);
                     }
                     $message = $account->getMessage($email);
                     $data = $message->getBodyPlain() ? $message->getBodyPlain() : strip_tags($message->getBodyHTML());
                     if ($data) {
                         if (mb_detect_encoding($data, 'UTF-8', true) === false) {
                             $data = utf8_encode($data);
                         }
                         $new_data = '';
                         foreach (explode("\n", $data) as $line) {
                             $line = trim($line);
                             if ($line) {
                                 $line = preg_replace('/^(_{2,}|-{2,})$/', "<hr>", $line);
                                 $new_data .= $line . "\n";
                             } else {
                                 $new_data .= "\n";
                             }
                         }
                         $data = nl2br($new_data, false);
                     }
                     // Parse the subject, and obtain the issues.
                     $parsed_commit = Issue::getIssuesFromTextByRegex(mb_decode_mimeheader($email->subject));
                     $issues = $parsed_commit["issues"];
                     // If any issues were found, add new comment to each issue.
                     if ($issues) {
                         foreach ($issues as $issue) {
                             $text = preg_replace('#(^\\w.+:\\n)?(^>.*(\\n|$))+#mi', "", $data);
                             $text = trim($text);
                             if (!$this->processIncomingEmailCommand($text, $issue) && $user->canPostComments()) {
                                 $comment = new Comment();
                                 $comment->setContent($text);
                                 $comment->setPostedBy($user);
                                 $comment->setTargetID($issue->getID());
                                 $comment->setTargetType(Comment::TYPE_ISSUE);
                                 $comment->save();
                             }
                         }
                     } else {
                         if ($user->canReportIssues($account->getProject())) {
                             $issue = new Issue();
                             $issue->setProject($account->getProject());
                             $issue->setTitle(mb_decode_mimeheader($email->subject));
                             $issue->setDescription($data);
                             $issue->setPostedBy($user);
                             $issue->setIssuetype($account->getIssuetype());
                             $issue->save();
                             // Append the new issue to the list of affected issues. This
                             // is necessary in order to process the attachments properly.
                             $issues[] = $issue;
                         }
                     }
                     // If there was at least a single affected issue, and mail
                     // contains attachments, add those attachments to related issues.
                     if ($issues && $message->hasAttachments()) {
                         foreach ($message->getAttachments() as $attachment_no => $attachment) {
                             echo 'saving attachment ' . $attachment_no;
                             $name = $attachment['filename'];
                             $new_filename = framework\Context::getUser()->getID() . '_' . NOW . '_' . basename($name);
                             if (framework\Settings::getUploadStorage() == 'files') {
                                 $files_dir = framework\Settings::getUploadsLocalpath();
                                 $filename = $files_dir . $new_filename;
                             } else {
                                 $filename = $name;
                             }
                             Logging::log('Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no);
                             echo 'Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no;
                             $content_type = $attachment['type'] . '/' . $attachment['subtype'];
                             $file = new File();
                             $file->setRealFilename($new_filename);
                             $file->setOriginalFilename(basename($name));
                             $file->setContentType($content_type);
                             $file->setDescription($name);
                             $file->setUploadedBy(framework\Context::getUser());
                             if (framework\Settings::getUploadStorage() == 'database') {
                                 $file->setContent($attachment['data']);
                             } else {
                                 Logging::log('Saving file ' . $new_filename . ' with content from attachment ' . $attachment_no);
                                 file_put_contents($new_filename, $attachment['data']);
                             }
                             $file->save();
                             // Attach file to each related issue.
                             foreach ($issues as $issue) {
                                 $issue->attachFile($file);
                             }
                         }
                     }
                     $count++;
                 }
             }
         } catch (\Exception $e) {
//.........这里部分代码省略.........
开发者ID:RTechSoft,项目名称:thebuggenie,代码行数:101,代码来源:Mailing.php


示例18: _mimeHeaderDecode

 /**
  * Decode MIME header elements
  *
  * @param string $header
  * @return string
  */
 protected function _mimeHeaderDecode($header)
 {
     return mb_decode_mimeheader($header);
     //return iconv_mime_decode($header, 0, 'UTF-8');
     /*
     $utf8Header = imap_utf8($header);
     $decoded = imap_mime_header_decode($utf8Header);
     if (isset($decoded[0])) {
         $decodedObj = $decoded[0];
         return $decodedObj->text;
     } else {
         return $utf8Header;
     }
     */
 }
开发者ID:onlime,项目名称:sendmail-wrapper,代码行数:21,代码来源:SendmailThrottle.php


示例19: getEmailFormat

 /**
  * Secret Sauce - Transform an email string
  * response to array key value format
  *
  * @param *string      $email    The actual email
  * @param string|null  $uniqueId The mail UID
  * @param array        $flags    Any mail flags
  *
  * @return array
  */
 private function getEmailFormat($email, $uniqueId = null, array $flags = array())
 {
     //if email is an array
     if (is_array($email)) {
         //make it into a string
         $email = implode("\n", $email);
     }
     //split the head and the body
     $parts = preg_split("/\n\\s*\n/", $email, 2);
     $head = $parts[0];
     $body = null;
     if (isset($parts[1]) && trim($parts[1]) != ')') {
         $body = $parts[1];
     }
     $lines = explode("\n", $head);
     $head = array();
     foreach ($lines as $line) {
         if (trim($line) && preg_match("/^\\s+/", $line)) {
             $head[count($head) - 1] .= ' ' . trim($line);
             continue;
         }
         $head[] = trim($line);
     }
     $head = implode("\n", $head);
     $recipientsTo = $recipientsCc = $recipientsBcc = $sender = array();
     //get the headers
     $headers1 = imap_rfc822_parse_headers($head);
     $headers2 = $this->getHeaders($head);
     //set the from
     $sender['name'] = null;
     if (isset($headers1->from[0]->personal)) {
         $sender['name'] = $headers1->from[0]->personal;
         //if the name is iso or utf encoded
         if (preg_match("/^\\=\\?[a-zA-Z]+\\-[0-9]+.*\\?/", strtolower($sender['name']))) {
             //decode the subject
             $sender['name'] = str_replace('_', ' ', mb_decode_mimeheader($sender['name']));
         }
     }
     $sender['email'] = $headers1->from[0]->mailbox . '@' . $headers1->from[0]->host;
     //set the to
     if (isset($headers1->to)) {
         foreach ($headers1->to as $to) {
             if (!isset($to->mailbox, $to->host)) {
                 continue;
             }
             $recipient = array('name' => null);
             if (isset($to->personal)) {
                 $recipient['name'] = $to->personal;
                 //if the name is iso or utf encoded
                 if (preg_match("/^\\=\\?[a-zA-Z]+\\-[0-9]+.*\\?/", strtolower($recipient['name']))) {
                     //decode the subject
                     $recipient['name'] = str_replace('_', ' ', mb_decode_mimeheader($recipient['name']));
                 }
             }
             $recipient['email'] = $to->mailbox . '@' . $to->host;
             $recipientsTo[] = $recipient;
         }
     }
     //set the cc
     if (isset($headers1->cc)) {
         foreach ($headers1->cc as $cc) {
             $recipient = array('name' => null);
             if (isset($cc->personal)) {
                 $recipient['name'] = $cc->personal;
                 //if the name is iso or utf encoded
                 if (preg_match("/^\\=\\?[a-zA-Z]+\\-[0-9]+.*\\?/", strtolower($recipient['name']))) {
                     //decode the subject
                     $recipient['name'] = str_replace('_', ' ', mb_decode_mimeheader($recipient['name']));
                 }
             }
             $recipient['email'] = $cc->mailbox . '@' . $cc->host;
             $recipientsCc[] = $recipient;
         }
     }
     //set the bcc
     if (isset($headers1->bcc)) {
         foreach ($headers1->bcc as $bcc) {
             $recipient = array('name' => null);
             if (isset($bcc->personal)) {
                 $recipient['name'] = $bcc->personal;
                 //if the name is iso or utf encoded
                 if (preg_match("/^\\=\\?[a-zA-Z]+\\-[0-9]+.*\\?/", strtolower($recipient['name']))) {
                     //decode the subject
                     $recipient['name'] = str_replace('_', ' ', mb_decode_mimeheader($recipient['name']));
                 }
             }
             $recipient['email'] = $bcc->mailbox . '@' . $bcc->host;
             $recipientsBcc[] = $recipient;
         }
     }
//.........这里部分代码省略.........
开发者ID:kamaroly,项目名称:Mail,代码行数:101,代码来源:Imap.php


示例20: loadStructure

 /**
  * Load structure and save every part of message to common array EmbeddedMessage::$structure
  */
 private function loadStructure()
 {
     $this->rawMimeHeader = imap_fetchmime($this->stream, $this->messageNumber, $this->partNumber, FT_UID);
     $this->parsedHeader = imap_rfc822_parse_headers($this->getContent());
     if (!count((array) $this->parsedHeader)) {
         $this->parsedHeader = imap_rfc822_parse_headers($this->rawMimeHeader);
     }
     //Message ID
     $this->id = $this->parsedHeader->message_id;
     //Email from
     $emailFrom = $this->parsedHeader->from[0];
     $emailFrom->personal = isset($emailFrom->personal) ? $emailFrom->personal : null;
     $this->from = new EmailAddress($emailFrom->mailbox, $emailFrom->host, imap_utf8($emailFrom->personal));
     //EmailsTo
     $emailsTo = [];
     $parsedEmails = $this->parsedHeader->to;
     foreach ($parsedEmails as $email) {
         $email->personal = isset($email->personal) ? $email->personal : null;
         $emailsTo[] = new EmailAddress($email->mailbox, $email->host, imap_utf8($email->personal));
     }
     $this->to = $emailsTo;
     //EmailsCC
     $emailsCc = [];
     $parsedEmails = isset($this->parsedHeader->cc) ? $this->parsedHeader->cc : [];
     foreach ($parsedEmails as $email) {
         $email->personal = isset($email->personal) ? $email->personal : null;
         $emailsCc[] = new EmailAddress($email->mailbox, $email->host, imap_utf8($email->personal));
     }
     $this->cc = $emailsCc;
     //Date
     $this->date = new \DateTime($this->parsedHeader->date);
     //Subject
     if (preg_match('/=\\?(.*?)\\?(.*?)\\?/', $this->parsedHeader->subject, $matchSubject)) {
         $subjectEncoding = strtolower($matchSubject[1]);
         switch ($subjectEncoding) {
             case "utf-8":
                 $this->subject = mb_decode_mimeheader($this->parsedHeader->subject);
                 break;
             default:
                 $this->subject = quoted_printable_decode(imap_utf8($this->parsedHeader->subject));
                 break;
         }
     } else {
         $this->subject = imap_utf8($this->parsedHeader->subject);
     }
     $this->structure = $this->parseStructure();
     //extract attachments from common structure
     $this->attachments = $this->parseAttachments();
 }
开发者ID:artemevsin,项目名称:imap,代码行数:52,代码来源:EmbeddedMessage.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mb_decode_numericentity函数代码示例发布时间:2022-05-15
下一篇:
PHP mb_convert_variables函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap