Php receiving email class receivemail is a PHP class specifically used to receive mails. it supports mail protocols such as POP3 and IMAP. You can receive emails and attachments. Chinese garbled solution *** decodethesubjectofchinese ** @ paramstring $ subject * @ returnsting * publicfunctionsubjec php receiving mail class
Receivemail is a PHP class used to receive mails. it supports mail protocols such as POP3 and IMAP. You can receive emails and attachments.
Chinese garbled solutions
/** * decode the subject of chinese * * @param string $subject * @return sting */public function subjectDecode($subject) {$beginStr = substr($subject, 0, 5);if($beginStr == '=?ISO') {$separator = '=?ISO-2022-JP';$toEncoding = 'ISO-2022-JP';} else {$separator = '=?GB2312';$toEncoding = 'GB2312';}$encode = strstr($subject, $separator);if ($encode) {$explodeArr = explode($separator, $subject);$length = count($explodeArr);$subjectArr = array();for($i = 0; $i < $length / 2; $i++) {$subjectArr[$i][] = $explodeArr[$i * 2];if (@$explodeArr[$i * 2 + 1]) {$subjectArr[$i][] = $explodeArr[$i * 2 + 1];}}foreach ($subjectArr as $arr) {$subSubject = implode($separator, $arr);if (count($arr) == 1) {$subSubject = $separator . $subSubject;}$begin = strpos($subSubject, "=?");$end = strpos($subSubject, "?=");$beginStr = '';$endStr = '';if ($end > 0) {if ($begin > 0) {$beginStr = substr($subSubject, 0, $begin);}if ((strlen($subSubject) - $end) > 2) {$endStr = substr($subSubject, $end + 2, strlen($subSubject) - $end - 2);}$str = substr($subSubject, 0, $end - strlen($subSubject));$pos = strrpos($str, "?");$str = substr($str, $pos + 1, strlen($str) - $pos);$subSubject = $beginStr . imap_base64($str) . $endStr;$subSubjectArr[] = iconv ( $toEncoding, 'utf-8', $subSubject );// mb_convert_encoding($subSubject, 'utf-8' ,'gb2312,ISO-2022-JP');}}$subject = implode('', $subSubjectArr);}return $subject;}
If (strtolower ($ sender-> mailbox )! = 'Mailer-daemon' & strtolower ($ sender-> mailbox )! = 'Postmaster ')
{$ Subject = $ this-> subjectDecode ($ mail_header-> subject );
The usage is as follows:
Connect (); // If connection fails give error message and exit // read all emails $ tot = $ obj-> getTotalMails (); // Total Mails in Inbox Return integer valueecho "received $ tot mail ::
"; For ($ I = $ tot; $ I> 0; $ I --) {$ head = $ obj-> getHeaders ($ I ); // read the obtained mail header information and return the array **. the array key values are (subject, to, toOth, toNameOth, from, fromName) echo "topic ::". $ head ['subobject']."
"; Echo" Recipient: ". $ head ['to']."
"; Echo" cc: ". $ head ['tooth ']."
"; Echo" Sender: ". $ head ['from']."
"; Echo" sender name: ". $ head ['fromname']."
"; Echo"
"; Echo"
**************************************** **************************************** ***********
"; Echo $ obj-> getBody ($ I); // email body $ str = $ obj-> GetAttach ($ I ,". /"); // Obtain the email attachment. the returned file names are separated by commas. For example. (mailid, Path to store file) $ ar = explode (",", $ str); foreach ($ ar as $ key => $ value) echo ($ value = "")? "": "Atteched File:". $ value ."
"; Echo"
------------------------------------------------------
"; // $ Obj-> deleteMails ($ I); // Delete Mail from Mail box} $ obj-> close_mailbox (); // Close Mail Box?>
? Receivemail. class. php requires support from the imap module.
\n";// display subjects of messagesfor ($i=1; $i<=$number; $i++) { $header = imap_header($imap, $i); echo "Subject: ", $header->Subject, "
\n";}imap_close($imap);?>
Imap_append :?? ? Append the string to the specified mailbox.
Imap_base64 :?? ? Decodes base64 encoding.
Imap_body :?? ? The internal text of the email.
Imap_check :?? ? Return email information.
Imap_close :?? ? Disable the imap link.
Imap_createmailbox :?? ? Create a new mailbox.
Imap_delete :?? ? Mark the email to be deleted.
Imap_deletemailbox :?? ? Delete an existing mailbox.
Imap_expunge :?? ? Delete a marked email.
Imap_fetchbody :?? ? Extract the specified part from the letter.
Imap_fetchstructure :?? ? Obtains the structure information of a letter.
Imap_header :?? ? Obtains the header information of a letter.
Imap_headers :?? ? Obtains the header information of all emails.
Imap_listmailbox :?? ? Obtain the mailbox list.
Imap_listsubscribed :?? ? Obtain the list of subscription mailboxes.
Imap_mail_copy :?? ? Copy the specified email to its mailbox.
Imap_mail_move :?? ? Move the specified email to its mailbox.
Imap_num_msg :?? ? Obtain the number of letters.
Imap_num_recent :?? ? Obtain the number of new emails.
Imap_open :?? ? Open the imap link.
Imap_ping :?? ? Check whether imap is connected.
Imap_renamemailbox :?? ? Change the email name.
Imap_reopen :?? ? Restart the imap link.
Imap_subscribe :?? ? Subscription mailbox.
Imap_undelete :?? ? Cancel deleting the email tag.
Imap_unsubscribe :?? ? Cancel the email subscription.
Imap_qprint :?? ? Convert the qp encoding to eight bits.
Imap_8bit :?? ? Convert eight bits into qp encoding.
Imap_binary :?? ? Convert eight bits into base64 encoding.
Imap_scanmailbox :?? ? Find whether a letter contains a specific string.
Imap_mailboxmsginfo :?? ? Obtain the current email address.
Imap_rfc822_write_address :?? ? Email address standardization.
Imap_rfc822_parse_adrlist :?? ? Resolve the email address.
Imap_setflag_full :?? ? Configure the letter flag.
Imap_clearflag_full :?? ? Clear the letter flag.
Imap_sort :?? ? Sort the mail headers.
Imap_fetchheader :?? ? Obtain the original header.
Imap_uid :?? ? Obtain the letter uid.
Imap_getmailboxes :?? ? Obtain detailed information about all emails.
Imap_getsubscribed :?? ? List all subscription mailboxes.
Imap_msgno :?? ? List consecutive uid messages.
Imap_search :?? ? Searches for specified standard letters.
Imap_last_error :?? ? The final error message.
Imap_errors :?? ? All error messages.
Imap_alerts :?? ? All warning information.
Imap_status :?? ? The current status information.
1 floor hdnlove 2012-04-10
Hi, I 'd like to ask. How can I use receivemail to receive emails? how can it be very slow to load data? Do you have a solution?