$mailServer="imap.exmail.qq.com"; //IMAP主机 $mailLink="{{$mailServer}:143}INBOX" ; //imagp连接地址:不同主机地址不同 $mailUser = '***'; //邮箱用户名 $mailPass = '***'; //邮箱密码 $mbox = imap_open($mailLink,$mailUser,$mailPass); //开启信箱imap_open $totalrows = imap_num_msg($mbox); //取得信件数 for ($i=1;$i<$totalrows;$i++){ $headers = imap_fetchheader($mbox, $i); //获取信件标头 $headArr = matchMailHead($headers); //匹配信件标头 $mailBody = imap_fetchbody($mbox, $i, 1); //获取信件正文 } function matchMailHead($str){ $headList = array(); $headArr = array( 'from', 'to', 'date', 'subject' ); foreach ($headArr as $key){ if(preg_match('/'.$key.':(.*?)[\n\r]/is', $str,$m)){ $match = trim($m[1]); $headList[$key] = $key=='date'?date('Y-m-d H:i:s',strtotime($match)):$match; } } return $headList; }
Fetch-masterIMAP's PHP library is a method for PHP to receive emails based on IMAP. It also analyzes the relevant settings and usage skills of PHP for receiving emails based on IMAP, and comes with instructions for IMAP-related functions.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
30 Sep 2016
Looking for a php/python library management program (similar to Baidu library, managing doc/pdf and other libraries)~~ It mainly needs to have search functions, especially file classification retrieval/file tag retrieval functions, no need for online conversion, online browsing!
22 Apr 2024
Function libraries and third-party libraries in PHP can extend the functionality of applications. The function library provides predefined functions that can be included through the include statement. Third-party libraries are available from sources such as Packagist, GitHub, and installed using Composer. Implement automatic loading of classes through autoloaders, such as automatic loading of the Guzzle library. Learn how to use the Dompdf third-party library to generate PDF files through practical cases, including loading the library, loading HTML content, and outputting PDF files. The integration of function libraries and third-party libraries greatly expands the functionality of PHP applications and improves development efficiency and project performance.
17 Apr 2024
The steps for writing a function library in PHP are as follows: Create a PHP file (such as myFunctions.php) to store the functions. Use the function keyword to define functions in a file. Include libraries in other scripts using require_once or include_once statements. Once a function library is included, its functions can be used.
26 Apr 2024
PHP function libraries can improve code reusability by encapsulating common tasks. To create a reusable library that supports different PHP versions: define the library and compatible PHP version ranges; handle version differences based on PHP version; package the library for use by other projects.
29 Jul 2016
:This article mainly introduces the collection of PHP libraries. Students who are interested in PHP tutorials can refer to it.
11 Apr 2024
PHP function libraries are organized in independent files according to different functions and uses, including core extensions (/ext/), core libraries (/libs/), PEAR function libraries (/pear/) and user-defined functions (/user/). With this organization, developers can easily reuse and extend code while maintaining modularity and maintainability.
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images