加入收藏 | 设为首页 | 会员中心 | 我要投稿 网站开发网_安阳站长网 (https://www.0518zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

PHP receiveMail实现收邮件功能

发布时间:2021-05-23 00:47:02 所属栏目:站长百科 来源:网络整理
导读:副标题#e# 用PHP来发邮件,相信大家都不陌生,但读取收件箱的话,接触就少了,这次总结下自己的经验,希望可以帮助大家. 注意: 1.PHP读取收件箱主要是利用imap扩展,所以在使用以下方法前,必须开启imap扩展模块的支持. 2.此方法支持中文,不会乱码,需要保持所有文

function getBody($mid,&$path,$imageList) // Get Message Body
{
if(!$this->marubox)
return false;

$body = $this->get_part($this->marubox,"TEXT/HTML"); 
if ($body == "") 
  $body = $this->get_part($this->marubox,"TEXT/PLAIN"); 
if ($body == "") {  
  return ""; 
} 
//处理图片 
$body=$this->embed_images($body,$path,$imageList); 
return $body; 

}

function embed_images(&$body,$imageList)
{
// get all img tags
preg_match_all('/<img.*?>/',$body,$matches);
if (!isset($matches[0])) return;

foreach ($matches[0] as $img) 
{ 
  // replace image web path with local path 
  preg_match('/src="(.*?)"/',$img,$m); 
  if (!isset($m[1])) continue; 
  $arr = parse_url($m[1]); 
  if (!isset($arr['scheme']) || !isset($arr['path']))continue; 

// if (!isset($arr['host']) || !isset($arr['path']))continue;
if ($arr['scheme']!="http")
{
$filename=explode("@",$arr['path']);
$body = str_replace($img,'PHP receiveMail实现收邮件功能',$body);
}
}
return $body;
}

function deleteMails($mid) // Delete That Mail
{
if(!$this->marubox)
return false;

imap_delete($this->marubox,$mid); 

}
function close_mailbox() //Close Mail Box
{
if(!$this->marubox)
return false;

imap_close($this->marubox,CL_EXPUNGE); 

}

(编辑:网站开发网_安阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!