本文整理汇总了PHP中Mail_mimeDecode::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail_mimeDecode::decode方法的具体用法?PHP Mail_mimeDecode::decode怎么用?PHP Mail_mimeDecode::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail_mimeDecode
的用法示例。
在下文中一共展示了Mail_mimeDecode::decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* メール受信時の処理
*
* @access public
* @author sakuragawa
*/
function execute()
{
ini_set('memory_limit', -1);
// 前処理
$this->beforefilter();
// メールの読み込み
$source = file_get_contents("php://stdin");
if (empty($source)) {
return;
}
// \nをつけてるのは、そのままだとSoftbankの空メールが取得できなかったから
$source .= "\n";
$this->hookMail($source);
// メールをデコード
//$this->out($this->params2);
$Decoder = new Mail_mimeDecode($source);
$mail = $Decoder->decode($this->mailMimeDecodeParams);
// Fromを取得
$from = $this->_parseAddress($mail, 'from');
$this->hookFromAddress($from);
// Toを取得
$to = $this->_parseAddress($mail, 'to');
$this->hookToAddress($to);
// 本文・添付等をパース
$this->_parseBody($mail);
$this->afterfilter();
// Toを取得
/*$to = $this->_getTo($mail);
$this->getTo($to);*/
}
示例2: GetMessage
function GetMessage($message_id, $external_id = 0)
{
if (!isset($this->_messageCash[$message_id])) {
$raw_message = $this->_pop3->getMsg($message_id);
require_once SYS . '/system/class/email/mime/mimeDecode.php';
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$decoder = new Mail_mimeDecode($raw_message);
$msg = $decoder->decode($params);
// Dump($msg, true);
$msg->external_id = $external_id;
if (isset($msg->headers['date'])) {
$msg->Moment = strtotime($msg->headers['date']);
} else {
$msg->Moment = 0;
}
$msg = $this->ProcessMessageBody($msg);
if (strtoupper($msg->charset) == 'KOI8-R') {
$msg->body = convert_cyr_string($msg->body, 'koi8-r', 'Windows-1251');
$msg->headers['subject'] = convert_cyr_string($msg->headers['subject'], 'koi8-r', 'Windows-1251');
$msg->charset = 'Windows-1251';
}
$this->_messageCash[$message_id] = $msg;
$this->got_inner_body = null;
}
return $this->_messageCash[$message_id];
}
示例3: decode
function decode()
{
$params = array('crlf' => "\r\n", 'input' => $this->mime_message, 'include_bodies' => $this->include_bodies, 'decode_headers' => $this->decode_headers, 'decode_bodies' => $this->decode_bodies);
$this->splitBodyHeader();
$this->struct = Mail_mimeDecode::decode($params);
return PEAR::isError($this->struct) || !(count($this->struct->headers) > 1) ? FALSE : TRUE;
}
示例4: processemail
public static function processemail($emailsrc, $pdfout, $coverfile = '')
{
$combfilelist = array();
# Process the email
$emailparts = Mail_mimeDecode::decode(array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true, 'input' => file_get_contents($emailsrc), 'crlf' => "\r\n"));
# Process the cover if it exists
if ($coverfile !== '') {
$combfilelist[] = self::processpart(file_get_contents($coverfile), mime_content_type($coverfile));
}
# Process the parts
$combfilelist = array_merge($combfilelist, self::processparts($emailparts));
# Create an intermediate file to build the pdf
$tmppdffilename = sys_get_temp_dir() . '/e2p-' . (string) abs((int) (microtime(true) * 100000)) . '.pdf';
# Build the command to combine all of the intermediate files into one
$conbcom = str_replace(array_merge(array('INTFILE', 'COMBLIST'), array_keys(self::$driver_paths)), array_merge(array($tmppdffilename, implode(' ', $combfilelist)), array_values(self::$driver_paths)), self::$mime_drivers['gs']);
exec($conbcom);
# Remove the intermediate files
foreach ($combfilelist as $combfilename) {
unlink($combfilename);
}
# Write the intermediate file to the final destination
$intfileres = fopen($tmppdffilename, 'rb');
$outfileres = fopen($pdfout, 'ab');
while (!feof($intfileres)) {
fwrite($outfileres, fread($intfileres, 8192));
}
fclose($intfileres);
fclose($outfileres);
# Remove the intermediate file
unlink($tmppdffilename);
}
示例5: testMimeDecode
function testMimeDecode($file, $new_file)
{
if (!defined('LOGLEVEL')) {
define('LOGLEVEL', LOGLEVEL_DEBUG);
}
if (!defined('LOGUSERLEVEL')) {
define('LOGUSERLEVEL', LOGLEVEL_DEVICEID);
}
printf("TEST MIME DECODE\n");
$mobj = new Mail_mimeDecode(file_get_contents($file));
$message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'charset' => 'utf-8'));
$handle = fopen($new_file, "w");
fwrite($handle, build_mime_message($message));
fclose($handle);
foreach ($message->headers as $k => $v) {
if (is_array($v)) {
foreach ($v as $vk => $vv) {
printf("Header <%s> <%s> <%s>\n", $k, $vk, $vv);
}
} else {
printf("Header <%s> <%s>\n", $k, $v);
}
}
$text = $html = "";
Mail_mimeDecode::getBodyRecursive($message, "plain", $text);
Mail_mimeDecode::getBodyRecursive($message, "html", $html);
printf("TEXT Body <%s>\n", $text);
printf("HTML Body <%s>\n", $html);
}
示例6: transport_email_receive
function transport_email_receive($pMsg)
{
global $gBitUser, $gBitSystem;
// prolly dont need this
// $connectionString = '{'.$gBitSystem->getConfig('transport_email_server','imap').':'.$gBitSystem->getConfig('transport_email_port','993').'/'.$gBitSystem->getConfig('transport_email_protocol','imap').'/ssl/novalidate-cert}';
// Parse msg - get header, body, attachments, to, from, reply header
if (include_once 'PEAR.php') {
if (require_once 'Mail/mimeDecode.php') {
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$decoder = new Mail_mimeDecode($pMsg);
if ($data = $decoder->decode($params)) {
if ($handler($data)) {
transport_email_expunge($pMsg);
}
} else {
//error
}
} else {
//error
}
} else {
//error
}
}
示例7: decode
/**
* メールをデコード
*
* @access public
* @param string メールの生データ
*/
function decode($raw_mail)
{
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = $raw_mail;
$this->mail =& Mail_mimeDecode::decode($params);
}
示例8: parse
public function parse($input)
{
$decoder = new Mail_mimeDecode($input, "\r\n");
$structure = $decoder->decode(array('include_bodies' => true, 'decode_bodies' => true));
$raw_mail = (array) $structure;
$raw_mail['body'] = $this->getBody($structure);
return $raw_mail;
}
示例9: array
{
private $paramsDecode = array('decode_headers' => TRUE, 'include_bodies' => TRUE, 'decode_bodies' => TRUE);
private $_decoded;
private $_email;
private $spf;
private $body;
private $subject;
private $fromEmail;
示例10: decodeEmail
function decodeEmail($input)
{
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$decoder = new Mail_mimeDecode($input);
$structure = $decoder->decode($params);
return $structure;
}
示例11: process
public function process()
{
$this->init();
ini_set('memory_limit', -1);
$debug = app()->request->getParam('debug');
$params = [];
//SUPPLIER_PRICES_DIR
$incoming = $debug ? file_get_contents($this->_rootPath . DS . "eml" . DS . "test.eml") : app()->request->getParam('@letter');
if (!$incoming) {
$this->log('не корректное получение письма', true);
}
$params = ['include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true];
$decoder = new Mail_mimeDecode($incoming);
$result = $decoder->decode($params);
preg_match_all('/\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+/', $result->headers["from"], $matches);
$mail = $matches[0];
//array with from emails
if (!$mail) {
$this->log("не установлен отправитель письма от {$result->headers['from']}", true);
}
$this->email = $mail[0];
// временный тестовый лог
if (isset($result->headers["subject"]) && is_array($result->headers["subject"])) {
$this->log("ОШИБКА в ParseLetter-e \nДата: " . CJSON::encode($result), true);
}
// Пример: Subject: [supplierId 9255]
if (isset($result->headers["subject"]) && strpos($result->headers["subject"], 'supplierId') !== false) {
$subject = $result->headers["subject"];
preg_match_all('/\\[.*?(\\d+)\\]/i', $subject, $matches);
$idSupplier = $matches[1][0];
} else {
$query = app()->db->createCommand()->select('id_supplier, email')->from('supplier_email c')->join('supplier s', 'c.id_supplier = s.id')->where('email = "' . $this->email . '"')->andWhere('follow_manual = 1')->queryRow();
$idSupplier = $query['id_supplier'];
}
if (!$idSupplier) {
// $this->log("{$this->email} :: не установлен поставщик или для поставщика отключена настройка 'Следить вручную'", true); //временно выключаем
Yii::app()->end();
}
$this->idSupplier = trim($idSupplier);
$this->_destFileDir = $this->_rootPath . $this->idSupplier . DS . 'new';
File::checkPermissions($this->_destFileDir);
setlocale(LC_ALL, 'ru_RU.UTF8');
if (isset($result->parts)) {
foreach ($result->parts as $key => $part) {
if ($part->ctype_primary == 'multipart') {
foreach ($part->parts as $k => $v) {
$this->mainProccess($v);
}
} else {
$this->mainProccess($part);
}
}
}
}
示例12: array
function &_parseMsg(&$msg)
{
$arr = array();
//Parse out attachments/HTML
$this->_params['input'] = $msg['msg'];
$structure = Mail_mimeDecode::decode($this->_params);
$body = $this->_getBody($structure);
$arr['hash'] = $this->_parseTicketID($structure->headers['subject']);
$arr['msg'] = $this->_parseBody($body);
$arr['mime_struct'] = $structure;
$arr = array_merge($arr, $this->_parseFrom($structure->headers['from']));
return $arr;
}
示例13: array
/**
* Returns a parsed MIME message
*
* @param string $text The text of the message
*
* @return array An array with the MIME parsed headers and body.
*/
function _mimeParse(&$text)
{
/* Taken from Horde's MIME/Structure.php */
require_once 'Mail/mimeDecode.php';
/* Set up the options for the mimeDecode class. */
$decode_args = array();
$decode_args['include_bodies'] = true;
$decode_args['decode_bodies'] = false;
$decode_args['decode_headers'] = false;
$mimeDecode = new Mail_mimeDecode($text, MIME_PART_EOL);
if (!($structure = $mimeDecode->decode($decode_args))) {
return false;
}
/* Put the object into imap_parsestructure() form. */
MIME_Structure::_convertMimeDecodeData($structure);
return array($structure->headers, $ret =& MIME_Structure::parse($structure));
}
示例14: parse
public function parse($raw)
{
$this->raw = $raw;
// http://pear.php.net/manual/en/package.mail.mail-mimedecode.decode.php
$decoder = new Mail_mimeDecode($this->raw);
$this->decoded = $decoder->decode(['decode_headers' => true, 'include_bodies' => true, 'decode_bodies' => true]);
$this->from = mb_convert_encoding($this->decoded->headers['from'], $this->charset, $this->charset);
$this->to = mb_convert_encoding($this->decoded->headers['to'], $this->charset, $this->charset);
$this->subject = mb_convert_encoding($this->decoded->headers['subject'], $this->charset, $this->charset);
$this->date = mb_convert_encoding($this->decoded->headers['date'], $this->charset, $this->charset);
$this->from_email = preg_replace('/.*<(.*)>.*/', "\$1", $this->from);
if (isset($this->decoded->parts) && is_array($this->decoded->parts)) {
foreach ($this->decoded->parts as $idx => $body_part) {
$this->decode_part($body_part);
}
}
if (isset($this->decoded->disposition) && $this->decoded->disposition == 'inline') {
$mime_type = "{$this->decoded->ctype_primary}/{$this->decoded->ctype_secondary}";
if (isset($this->decoded->d_parameters) && array_key_exists('filename', $this->decoded->d_parameters)) {
$filename = $this->decoded->d_parameters['filename'];
} else {
$filename = 'file';
}
if ($this->is_valid_attachment($mime_type)) {
$this->save_attachment($filename, $this->decoded->body, $mime_type);
}
$this->body = "";
}
// We might also have uuencoded files. Check for those.
if (empty($this->body)) {
$this->body = isset($this->decoded->body) ? $this->decoded->body : "";
}
if (preg_match("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $this->body) > 0) {
foreach ($decoder->uudecode($this->body) as $file) {
// $file = [ 'filename' => $filename, 'fileperm' => $fileperm, 'filedata' => $filedata ]
$this->save_attachment($file['filename'], $file['filedata']);
}
// Strip out all the uuencoded attachments from the body
while (preg_match("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $this->body) > 0) {
$this->body = preg_replace("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", "\n", $this->body);
}
}
$this->body = mb_convert_encoding($this->body, $this->charset, $this->charset);
return $this;
}
示例15: parse
/**
* 標準入力からメールを読み込み、必要な情報を取得する。
*
* @return void
*/
function parse()
{
if (@$this->parsed) {
return;
}
require_once DATA_PATH . '/module/Mail/mimeDecode.php';
$fp = fopen('php://stdin', 'r');
// From 行を解析する。
$from_line = rtrim(fgets($fp));
if (preg_match('/^From\\s+"?([^\\s"@]+)"?@([^\\s@]+)/', $from_line, $matches)) {
$this->sender = $matches[1] . '@' . $matches[2];
} else {
trigger_error("Invalid from line: {$from_line}");
$this->sender = null;
}
// 残りのヘッダーを解析する。
$data = '';
while (!feof($fp)) {
$data .= fgets($fp);
if (rtrim($data, "\r\n") == '') {
break;
}
}
$structure = Mail_mimeDecode::decode(array('input' => $data));
$this->recipient = @$structure->headers['to'];
// 宛先アドレスから拡張部分を取得する。
$pos = strpos($this->recipient, MOBILE_KARA_MAIL_ADDRESS_DELIMITER);
if ($pos !== false) {
$extension_and_domain = substr($this->recipient, $pos + 1);
$pos = strpos($extension_and_domain, '@');
if ($pos !== false) {
$this->extension = substr($extension_and_domain, 0, $pos);
} else {
$this->extension = $extension_and_domain;
}
} else {
trigger_error("Invalid recipient: {$this->recipient}");
$this->extension = null;
}
$this->parsed = true;
}