Home php教程 php手册 最好的邮件编码解码类,再没有比这个好的了贴不下了1

最好的邮件编码解码类,再没有比这个好的了贴不下了1

Jun 13, 2016 am 10:27 AM
decode else most Compare kind coding decoding this mail

class mime_decode { var $content = Array(); function mime_encode_headers($string) { if($string == "") return; if(!eregi("^([[:print:]]*)$",$string)) $string = "=?ISO-8859-1?Q?".str_replace("+","_",str_replace("%","=",urlencode($string)))."?="; return $string; } function decode_mime_string($string) { if(($pos = strpos($string,"=?")) === false) return $string; while(!($pos === false)) { $newresult .= substr($string,0,$pos); $string = substr($string,$pos+2,strlen($string)); $intpos = strpos($string,"?"); $charset = substr($string,0,$intpos); $enctype = strtolower(substr($string,$intpos+1,1)); $string = substr($string,$intpos+3,strlen($string)); $endpos = strpos($string,"?="); $mystring = substr($string,0,$endpos); $string = substr($string,$endpos+2,strlen($string)); if($enctype == "q") { $mystring = str_replace("_"," ",$mystring); $mystring = $this->decode_qp($mystring); } else if ($enctype == "b") $mystring = base64_decode($mystring); $newresult .= $mystring; $pos = strpos($string,"=?"); } return $newresult.$string; } function decode_header($header) { $headers = explode(" ",$header); $decodedheaders = Array(); for($i=0;$i"; $closed = 1; for($i=0;$i", $thisPart, $regs)) { $email = trim($regs[2]); $name = trim($regs[1]); } else { if (eregi("([-a-z0-9_$+.]+@[-a-z0-9_.]+[-a-z0-9_]+)((.*))", $thisPart, $regs)) { $email = $regs[1]; $name = $regs[2]; } else $email = $thisPart; } $email = eregi_replace("^$", "\1", $email); $name = eregi_replace("^"(.*)"$", "\1", trim($name)); $name = eregi_replace("^((.*))$", "\1", $name); if ($name == "") $name = $email; if ($email == "") $email = $name; $ARfrom[$i]["name"] = $this->decode_mime_string($name); $ARfrom[$i]["mail"] = $email; unset($name);unset($email); } } return $ARfrom; } function build_alternative_body($ctype,$body) { global $mime_show_html; $boundary = $this->get_boundary($ctype); $part = $this->split_parts($boundary,$body); $thispart = ($mime_show_html)?$part[1]:$part[0]; $email = $this->fetch_structure($thispart); $header = $email["header"]; $body = $email["body"]; $headers = $this->decode_header($header); $body = $this->compile_body($body,$headers["content-transfer-encoding"]); return $body; } function build_related_body($ctype,$body) { global $mime_show_html,$sid,$lid,$ix,$folder; $Rtype = trim(substr($ctype,strpos($ctype,"type=")+5,strlen($ctype))); if(strpos($Rtype,";") != 0) $Rtype = substr($Rtype,0,strpos($Rtype,";")); if(substr($Rtype,0,1) == """ && substr($Rtype,-1) == """) $Rtype = substr($Rtype,1,strlen($Rtype)-2); $boundary = $this->get_boundary($ctype); $part = $this->split_parts($boundary,$body); for($i=0;$ifetch_structure($part[$i]); $header = $email["header"]; $body = $email["body"]; $headers = $this->decode_header($header); $ctype = $headers["content-type"]; $cid = $headers["content-id"]; $Actype = split(";",$headers["content-type"]); $types = split("/",$Actype[0]); $rctype = strtolower($Actype[0]); if($rctype == "multipart/alternative") $msgbody = $this->build_alternative_body($ctype,$body); elseif($rctype == "text/plain" && strpos($headers["content-disposition"],"name") === false) { $body = $this->compile_body($body,$headers["content-transfer-encoding"]); $msgbody = $this->build_text_body($body); } elseif($rctype == "text/html" && strpos($headers["content-disposition"],"name") === false) { $body = $this->compile_body($body,$headers["content-transfer-encoding"]); if(!$mime_show_html) $body = $this->build_text_body(strip_tags($body)); $msgbody = $body; } else { $thisattach = $this->build_attach($header,$body,$boundary,$i); if($cid != "") { if(substr($cid,0,1) == "") $cid = substr($cid,1,strlen($cid)-2); $cid = "cid:$cid"; $thisfile = "download.php?sid=$sid&lid=$lid&folder=".urlencode($folder)."&ix=".$ix."&bound=".base64_encode($thisattach["boundary"])."&part=".$thisattach["part"]."&filename=".urlencode($thisattach["name"]); $msgbody = str_replace($cid,$thisfile,$msgbody); } } } return $msgbody; } function linesize($message="", $length=70) { $line = explode(" ",$message); unset($message); for ($i=0 ;$i $length and $buf_o != "") { $message .= "$buf_o "; $buf = $line_part[$e]; } } $message .= "$buf "; } return($message); }

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Outlook emails lost from control panel in Windows 11 Outlook emails lost from control panel in Windows 11 Feb 29, 2024 pm 03:16 PM

Is the Outlook mail icon missing from Windows 11's Control Panel? This unexpected situation has caused confusion and concern among some individuals who rely on OutlookMail for their communication needs. Why don't my Outlook emails show up in Control Panel? There may be several possible reasons why there are no Outlook mail icons in Control Panel: Outlook is not installed correctly. Installing Office applications from the Microsoft Store does not add the Mail applet to Control Panel. The location of the mlcfg32.cpl file in Control Panel is missing. The path to the mlcfg32.cpl file in the registry is incorrect. The operating system is not currently configured to run this application

Word mail merge prints blank page Word mail merge prints blank page Feb 19, 2024 pm 04:51 PM

If you find that blank pages appear when printing a mail merge document using Word, this article will help you. Mail merge is a convenient feature that allows you to easily create personalized documents and send them to multiple recipients. In Microsoft Word, the mail merge feature is highly regarded because it helps users save time manually copying the same content for each recipient. In order to print the mail merge document, you can go to the Mailings tab. But some Word users have reported that when trying to print a mail merge document, the printer prints a blank page or doesn't print at all. This may be due to incorrect formatting or printer settings. Try checking the document and printer settings and make sure to preview the document before printing to ensure the content is correct. if

Advanced usage and skill sharing of Oracle DECODE function Advanced usage and skill sharing of Oracle DECODE function Mar 08, 2024 am 10:30 AM

The DECODE function in Oracle database is a very commonly used function, which can select among a set of values ​​based on the result value of an expression. The syntax of the DECODE function is as follows: DECODE(expression, search_value1, result1, search_value2, result2,..., default_result) where expression is the expression to be compared, s

Knowledge graph: the ideal partner for large models Knowledge graph: the ideal partner for large models Jan 29, 2024 am 09:21 AM

Large language models (LLMs) have the ability to generate smooth and coherent text, bringing new prospects to areas such as artificial intelligence conversation and creative writing. However, LLM also has some key limitations. First, their knowledge is limited to patterns recognized from training data, lacking a true understanding of the world. Second, reasoning skills are limited and cannot make logical inferences or fuse facts from multiple data sources. When faced with more complex and open-ended questions, LLM's answers may become absurd or contradictory, known as "illusions." Therefore, although LLM is very useful in some aspects, it still has certain limitations when dealing with complex problems and real-world situations. In order to bridge these gaps, retrieval-augmented generation (RAG) systems have emerged in recent years. The core idea is

How to use real-time voicemail transcription on iPhone How to use real-time voicemail transcription on iPhone Nov 18, 2023 pm 04:03 PM

What is real-time voicemail transcription? Live Voicemail Transcription is an innovative feature introduced in iOS 16 that allows iPhone users to view a live transcription of their voicemail while leaving it. This feature utilizes advanced speech recognition technology to convert spoken words into text, providing a convenient and accessible way to stay up to date on the latest news without having to listen to them entirely. Benefits of Using Live Voicemail Transcription Live Voicemail Transcription offers several advantages to iPhone users: Improved Productivity: By providing real-time transcription, Live Voicemail Transcription saves users time and effort by eliminating the need to listen to the entire voicemail. . This allows users to quickly scan the content of voicemails and prioritize their responses. Accessibility for hearing-impaired users

Oracle DECODE function detailed explanation and usage examples Oracle DECODE function detailed explanation and usage examples Mar 08, 2024 pm 03:51 PM

The DECODE function in Oracle is a conditional expression that is often used to return different results based on different conditions in query statements. This article will introduce the syntax, usage and sample code of the DECODE function in detail. 1. DECODE function syntax DECODE(expr,search1,result1[,search2,result2,...,default]) expr: the expression or field to be compared. search1,

Win10 Mail cannot access this account solution Win10 Mail cannot access this account solution Jan 07, 2024 pm 03:02 PM

Win10 mailbox exists in the system that comes with Win10. Many times the default settings will cause a lot of trouble to users. For example, when using it, you find that you cannot access this account. So how to solve this problem? Let’s take a look below. What to do if Win10 Mail cannot access this account: 1. Press "Win+I" to open "Windows Settings" 2. Click "Privacy" 3. Find "E-mail" on the left taskbar 4. Turn on the option in the picture

How to implement encoding and decoding of Chinese characters in C language programming? How to implement encoding and decoding of Chinese characters in C language programming? Feb 19, 2024 pm 02:15 PM

In modern computer programming, C language is one of the most commonly used programming languages. Although the C language itself does not directly support Chinese encoding and decoding, we can use some technologies and libraries to achieve this function. This article will introduce how to implement Chinese encoding and decoding in C language programming software. First, to implement Chinese encoding and decoding, we need to understand the basic concepts of Chinese encoding. Currently, the most commonly used Chinese encoding scheme is Unicode encoding. Unicode encoding assigns a unique numeric value to each character so that when calculating

See all articles