本文整理汇总了PHP中imap_mime_header_decode函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_mime_header_decode函数的具体用法?PHP imap_mime_header_decode怎么用?PHP imap_mime_header_decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_mime_header_decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pop_subject
function pop_subject()
{
$username = 'inz_agi01';
$password = 'ggwwds';
$imap = imap_open("{pop3.163.com:995/pop3/ssl/novalidate-cert}", $username, $password);
// $imap = imap_open("{pop.21cn.com:110/pop/notls}", $username, $password);
$message_count = imap_num_msg($imap);
echo "------->>" . is_int($message_count);
echo '$message_count' . $message_count . "\n";
for ($i = $message_count; $i >= 1; $i--) {
$header = imap_header($imap, $i);
$date = $header->date;
echo "************msg no: {$i} \n {$date} \n";
$subjectArr = @imap_mime_header_decode($header->subject);
if (is_array($subjectArr)) {
$subject = '';
foreach ($subjectArr as $subjectObj) {
//遍历标题数组,获取所有标题text
$subject .= trim($subjectObj->text);
}
$mailCharset = mb_detect_encoding($subject, array('UTF-8', 'GBK', 'LATIN1', 'BIG5'));
echo $mailCharset . "\n";
//查看邮件标题的编码
$subject = mb_convert_encoding($subject, 'utf-8', $mailCharset);
//对标题进行解码操作
echo $subject . "\n";
} else {
continue;
}
}
imap_close($imap);
}
示例2: actionIndex
public function actionIndex()
{
$model = new Receive();
error_reporting(E_ALL ^ E_WARNING);
$obj = new receiveMail('tclrg', 'Luanruitest', 'tclrg@126.com', 'imap.126.com', 'imap', '993', 'ture');
$obj->connect();
$tot = $obj->getTotalMails();
//查看邮箱是否有新邮件
$old_email_count = Email::find()->count();
for ($i = $tot; $i > $old_email_count; $i--) {
$model = new Receive();
$head = $obj->getHeaders($i);
$head['subject'] = imap_mime_header_decode($head['subject'])[0]->text;
$head['from'] = imap_mime_header_decode($head['from'])[0]->text;
$head['fromName'] = imap_mime_header_decode($head['fromName'])[0]->text;
$model->subject = $head['subject'];
$model->sender = $head['from'];
// echo $i.$head['date']."</br>";
// echo $i.strtotime($head['date'])."</br>";
// echo $i.date("Y-m-d H:i:s",strtotime($head['date']))."</br>";
$model->sendtime = date("Y-m-d H:i:s", strtotime($head['date']));
$model->text = $obj->getBody($i);
// $model->sendtime=$head['date'];
$model->save();
// echo $i.$head['date'];
}
$obj->close_mailbox();
}
示例3: decode
protected function decode($value)
{
if (empty($value) || ($value = '')) {
return '';
}
$decoded = '';
$parts = imap_mime_header_decode($value);
foreach ($parts as $part) {
$charset = 'default' == $part->charset ? 'auto' : $part->charset;
// imap_utf8 doesn't seem to work properly, so use Transcoder instead
try {
$decoded .= Transcoder::create()->transcode($part->text, $charset);
} catch (\Ddeboer\Transcoder\Exception\UndetectableEncodingException $ex) {
$decoded .= $part->text;
} catch (\Ddeboer\Transcoder\Exception\UnsupportedEncodingException $ex) {
$decoded .= $part->text;
} catch (\Ddeboer\Transcoder\Exception\IllegalCharacterException $ex) {
// force transcoding using iconv and ignore.
$decoded .= @iconv($charset, 'UTF-8//IGNORE', $part->text);
} catch (\Exception $ex) {
// maybe any kind of exception.
$decoded .= $part->text;
}
}
return $decoded;
}
示例4: getHeaders
function getHeaders($mid)
{
if (!$this->marubox) {
return false;
}
$mail_header = imap_header($this->marubox, $mid);
$sender = $mail_header->from[0];
// var_dump(strtolower($sender->mailbox));
// return $this->marubox;
$sender_replyto = $mail_header->reply_to[0];
$mail_details = array();
if (strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster') {
date_default_timezone_set('PRC');
$subject = imap_mime_header_decode($mail_header->subject);
$toaddress = imap_mime_header_decode($mail_header->toaddress);
$mail_details = array('from' => strtolower($sender->mailbox) . '@' . $sender->host, 'fromName' => "", 'fromName_charset' => "", 'toOth' => strtolower($sender_replyto->mailbox) . '@' . $sender_replyto->host, 'toNameOth' => "", 'subject' => $subject[0]->text, 'subject_charset' => $subject[0]->charset, 'mailDate' => date("Y-m-d H:i:s", $mail_header->udate), 'udate' => $mail_header->udate, 'to' => $toaddress[0]->text);
if (isset($sender->personal)) {
$sPersonal = imap_mime_header_decode($sender->personal);
$mail_details['fromName'] = $sPersonal[0]->text;
$mail_details['fromName_charset'] = $sPersonal[0]->charset;
}
if (isset($sender_replyto->personal)) {
$rePersonal = imap_mime_header_decode($sender_replyto->personal);
$mail_details['toNameOth'] = $rePersonal[0]->text;
}
}
return $mail_details;
}
示例5: decode
protected function decode($value)
{
$decoded = '';
$parts = imap_mime_header_decode($value);
try {
foreach ($parts as $part) {
$charset = 'default' == $part->charset ? 'auto' : $part->charset;
//Ajout COGIVEA fix encoding :
$charset = $this->charset != '' && $charset == 'auto' ? $this->charset : $charset;
//print $part->text."#".$this->charset."/".$charset."#"."\n";
// imap_utf8 doesn't seem to work properly, so use Transcoder instead
// Got from: https://github.com/Sawered/imap/commit/e739b7221c6e57521b38f7b56f78ba399acda888 and changed to UndetectableEncodingException
try {
$decoded .= Transcoder::create()->transcode($part->text, $charset);
} catch (IllegalCharacterException $e) {
//no warn, itis reality
//FIX COGIVEA
} catch (UndetectableEncodingException $e) {
//no warn, it is reality, handle it somehow
$decoded = imap_utf8($part->text);
}
}
} catch (Exception $e) {
}
return $decoded;
}
示例6: decode
public static function decode($string)
{
$parts = imap_mime_header_decode($string);
$s = '';
foreach ($parts as $part) {
$s .= $part->text;
}
return $s;
}
示例7: flat_mime_decode
function flat_mime_decode($string)
{
$array = imap_mime_header_decode($string);
$str = "";
foreach ($array as $key => $part) {
$str .= str_replace(['{', '}'], ['[', ']'], $part->text);
}
return $str;
}
示例8: decode_imap_text
function decode_imap_text($str)
{
$result = '';
$decode_header = imap_mime_header_decode($str);
foreach ($decode_header as $obj) {
$result .= htmlspecialchars(rtrim($obj->text, "\t"));
}
return $result;
}
示例9: decodeHeaderValue
/**
* Decodes a header value
* @param string $value The value to decode
* @return string Decoded value
*/
public function decodeHeaderValue($value)
{
$result = '';
$tokens = imap_mime_header_decode($value);
foreach ($tokens as $token) {
$result .= $token->text;
}
return $result;
}
示例10: get_plain_text_subject
function get_plain_text_subject($mbox, $msgNum, $headers = null)
{
$headers or $headers = imap_headerinfo($mbox, $msgNum);
$subjectParts = imap_mime_header_decode($headers->Subject);
$subject = '';
foreach ($subjectParts as $p) {
$subject .= $p->text;
}
return trim($subject);
}
示例11: unmime
function unmime($s)
{
// decodage mime (=?iso-8859-1?Q?l=E9a?= et autres =?iso-8859-1?B?bOlh?=)
$elements = imap_mime_header_decode($s);
$s = "";
for ($i = 0; $i < count($elements); $i++) {
$s .= $elements[$i]->text;
}
return $s;
}
示例12: decode
protected function decode($value)
{
$decoded = '';
$parts = imap_mime_header_decode($value);
foreach ($parts as $part) {
$charset = 'default' == $part->charset ? 'auto' : $part->charset;
// imap_utf8 doesn't seem to work properly, so use Transcoder instead
$decoded .= Transcoder::create()->transcode($part->text, $charset);
}
return $decoded;
}
示例13: decode
/**
* @param string $text
* @param string $targetCharset
*
* @return string
*/
public static function decode($text, $targetCharset = 'utf-8')
{
if (null === $text) {
return null;
}
$result = '';
foreach (imap_mime_header_decode($text) as $word) {
$ch = 'default' === $word->charset ? 'ascii' : $word->charset;
$result .= Message::charsetConvert($word->text, $ch, $targetCharset) ?: $word->text;
}
return $result;
}
示例14: setName
/**
* Set email owner name.
*
* @param string $name
*/
public function setName($name)
{
if (is_string($name)) {
$this->raw_name = $name;
$name = imap_mime_header_decode($name);
if (empty($name[0])) {
$this->name = '';
} else {
$this->name = $name[0]->text;
}
}
}
示例15: decodeMimeStr
function decodeMimeStr($string, $charset = "UTF-8")
{
$newString = '';
$elements = imap_mime_header_decode($string);
for ($i = 0; $i < count($elements); $i++) {
if ($elements[$i]->charset == 'default' || $elements[$i]->charset == 'x-unknown') {
$elements[$i]->charset = 'iso-8859-1';
}
$newString .= iconv($elements[$i]->charset, $charset, $elements[$i]->text);
}
return $newString;
}