search
HomePHP LibrariesOther librariesFetch-masterIMAP PHP library
Fetch-masterIMAP PHP library
$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.

Disclaimer

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

Memcache vs. Memcached: Which PHP Library Should You Choose?Memcache vs. Memcached: Which PHP Library Should You Choose?

09Nov2024

Distinguishing "Memcache" and "Memcached" in PHPPHP offers two memcached libraries: memcache and memcached. Understanding their differences helps...

Memcache vs Memcached: Which PHP Memcached Library Should You Choose?Memcache vs Memcached: Which PHP Memcached Library Should You Choose?

19Nov2024

Memcache vs Memcached: Choosing the Right PHP Memcached LibraryIntroductionPHP offers two seemingly similar memcached libraries: memcache and...

Which PHP Library Best Fits Your Email Address Validation Needs?Which PHP Library Best Fits Your Email Address Validation Needs?

18Nov2024

PHP Email Address Validation Libraries UncoveredEmail address validation plays a crucial role in data validation, but creating a...

How Do I Link Static Libraries That Depend on Other Static Libraries?How Do I Link Static Libraries That Depend on Other Static Libraries?

13Dec2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

laravel - What should the standardized PHP class library naming look like?laravel - What should the standardized PHP class library naming look like?

06Jul2016

I have seen many open source projects in the form of class.classname.php, but I have also seen many frameworks in the form of classname.class.php. Where should I place this class? I personally prefer the .class.php form, because in some frameworks, after importing third-party class libraries and specifying class libraries...

Memcache vs. Memcached: Which PHP Caching Library Should You Choose?Memcache vs. Memcached: Which PHP Caching Library Should You Choose?

12Nov2024

Memcache vs. Memcached: Choosing the Right PHP Library for Your Cache NeedsIn the realm of PHP caching libraries, Memcache and Memcached stand out...

See all articles