php ssl pop3,IMAP、POP3、 NNTP(邮件传输协议)

IMAP、POP3、 NNTP(邮件传输协议)

Convertan8bitstringtoaquoted-printablestring

ReturnsallIMAPalertmessagesthathaveoccurred

Appendastringmessagetoaspecifiedmailbox

DecodeBASE64encodedtext

Convertan8bitstringtoabase64string

Readthemessagebody

Readthestructureofaspecifiedbodysectionofaspecificmessage

Checkcurrentmailbox

Clearsflagsonmessages

CloseanIMAPstream

别名imap_createmailbox()

Markamessagefordeletionfromcurrentmailbox

ReturnsalloftheIMAPerrorsthathaveoccurred

Deleteallmessagesmarkedfordeletion

Readanoverviewoftheinformationintheheadersofthegivenmessage

Fetchaparticularsectionofthebodyofthemessage

Returnsheaderforamessage

FetchMIMEheadersforaparticularsectionofthemessage

Readthestructureofaparticularmessage

ClearsIMAPcache

Retrievethequotalevelsettings,andusagestaticspermailbox

Retrievethequotasettingsperuser

GetstheACLforagivenmailbox

Readthelistofmailboxes,returningdetailedinformationoneachone

Listallthesubscribedmailboxes

别名imap_headerinfo()

Readtheheaderofthemessage

Returnsheadersforallmessagesinamailbox

GetsthelastIMAPerrorthatoccurredduringthispagerequest

Readthelistofmailboxes

Returnsthelistofmailboxesthatmatchesthegiventext

Listallthesubscribedmailboxes

CreateaMIMEmessagebasedongivenenvelopeandbodysections

Copyspecifiedmessagestoamailbox

Sendanemailmessage

Getinformationaboutthecurrentmailbox

GetsthemessagesequencenumberforthegivenUID

DecodeamodifiedUTF-7stringtoUTF-8

Getsthenumberofmessagesinthecurrentmailbox

Getsthenumberofrecentmessagesincurrentmailbox

OpenanIMAPstreamtoamailbox

CheckiftheIMAPstreamisstillactive

Convertaquoted-printablestringtoan8bitstring

别名imap_renamemailbox()

Renameanoldmailboxtonewmailbox

ReopenIMAPstreamtonewmailbox

Parsemailheadersfromastring

Returnsaproperlyformattedemailaddressgiventhemailbox,host,andpersonalinfo

Saveaspecificbodysectiontoafile

别名imap_listscan()

Thisfunctionreturnsanarrayofmessagesmatchingthegivensearchcriteria

Setsaquotaforagivenmailbox

SetstheACLforagivenmailbox

Setsflagsonmessages

Getsandsortmessages

Returnsstatusinformationonamailbox

Subscribetoamailbox

Returnsatreeofthreadedmessage

Setorfetchimaptimeout

ThisfunctionreturnstheUIDforthegivenmessagesequencenumber

Unmarkthemessagewhichismarkeddeleted

Unsubscribefromamailbox

DecodesamodifiedUTF-7encodedstring

将ISO-8859-1字符串转换为修改的UTF-7文本

EncodeaUTF-8stringtomodifiedUTF-7

ConvertsMIME-encodedtexttoUTF-8

安装

要使这些函数生效,你必须在编译 PHP 的时候添加 --with-imap[=DIR] 选项, DIR 表示c-client安装前缀。比如上面提到的例子中,你可以使用 --with-imap=/usr/local/imap-2000b. 根据以上描述,这个路径是指向你先前创建的文件夹。对于 Windows 用户,应该在php.ini文件中引入php_imap.dll.

Windows 2000之前的系统是不支持的 IMAP 的。这是因为通过SSL连接邮件服务器时使用了加密功能。Note: 因为取决于 c-client 是如何配置的,所以你应该向 PHP 配置行添加--with-imap-ssl=/path/to/openssl/ 或者 --with-kerberos=/path/to/kerberos 配置信息。Warning

IMAP,recode,YAZ 和 Cyrus 扩展不能同时使用,因为它们共享了相同 的内部符号。注意:Yaz2.0 及以上版本不存在此问题。

运行时配置

这些函数的行为受php.ini中的设置影响。

IMAP 配置选项名字默认可修改范围更新日志imap.enable_insecure_rsh"0"PHP_INI_SYSTEMAvailable as of PHP 7.1.25, 7.2.13 and 7.3.0. Formerly, it was implicitly enabled.For all the people coming here praying for:

1) a dead-easy way to read MIME attachments, or

2) a dead-easy way to access POP3 folders

Look no further.

function pop3_login($host,$port,$user,$pass,$folder="INBOX",$ssl=false)

{

$ssl=($ssl==false)?"/novalidate-cert":"";

return (imap_open("{"."$host:$port/pop3$ssl"."}$folder",$user,$pass));

}

function pop3_stat($connection)

{

$check = imap_mailboxmsginfo($connection);

return ((array)$check);

}

function pop3_list($connection,$message="")

{

if ($message)

{

$range=$message;

} else {

$MC = imap_check($connection);

$range = "1:".$MC->Nmsgs;

}

$response = imap_fetch_overview($connection,$range);

foreach ($response as $msg) $result[$msg->msgno]=(array)$msg;

return $result;

}

function pop3_retr($connection,$message)

{

return(imap_fetchheader($connection,$message,FT_PREFETCHTEXT));

}

function pop3_dele($connection,$message)

{

return(imap_delete($connection,$message));

}

function mail_parse_headers($headers)

{

$headers=preg_replace('/\r\n\s+/m', '',$headers);

preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)?\r\n/m', $headers, $matches);

foreach ($matches[1] as $key =>$value) $result[$value]=$matches[2][$key];

return($result);

}

function mail_mime_to_array($imap,$mid,$parse_headers=false)

{

$mail = imap_fetchstructure($imap,$mid);

$mail = mail_get_parts($imap,$mid,$mail,0);

if ($parse_headers) $mail[0]["parsed"]=mail_parse_headers($mail[0]["data"]);

return($mail);

}

function mail_get_parts($imap,$mid,$part,$prefix)

{

$attachments=array();

$attachments[$prefix]=mail_decode_part($imap,$mid,$part,$prefix);

if (isset($part->parts)) // multipart

{

$prefix = ($prefix == "0")?"":"$prefix.";

foreach ($part->parts as $number=>$subpart)

$attachments=array_merge($attachments, mail_get_parts($imap,$mid,$subpart,$prefix.($number+1)));

}

return $attachments;

}

function mail_decode_part($connection,$message_number,$part,$prefix)

{

$attachment = array();

if($part->ifdparameters) {

foreach($part->dparameters as $object) {

$attachment[strtolower($object->attribute)]=$object->value;

if(strtolower($object->attribute) == 'filename') {

$attachment['is_attachment'] = true;

$attachment['filename'] = $object->value;

}

}

}

if($part->ifparameters) {

foreach($part->parameters as $object) {

$attachment[strtolower($object->attribute)]=$object->value;

if(strtolower($object->attribute) == 'name') {

$attachment['is_attachment'] = true;

$attachment['name'] = $object->value;

}

}

}

$attachment['data'] = imap_fetchbody($connection, $message_number, $prefix);

if($part->encoding == 3) { // 3 = BASE64

$attachment['data'] = base64_decode($attachment['data']);

}

elseif($part->encoding == 4) { // 4 = QUOTED-PRINTABLE

$attachment['data'] = quoted_printable_decode($attachment['data']);

}

return($attachment);

}

?>

[EDIT BY danbrown AT php DOT net: Contains a bugfix by "mn26826" on 09-JUN-2010, which fixed the erroneous reference to $imap as the parameter passed to imap_mailboxmsginfo() within the user function pop3_stat(). This was intended to be $connection.]

[EDIT BY visualmind AT php DOT net: Contains a bugfix by "elias-jobview" on 17-AUG-2010, which fixed the error in pop3_list function which didn't have: return $result]

[EDIT BY danbrown AT php DOT net: Contains a bugfix by "chrismeistre" on 09-SEP-2010, which fixed the erroneous reference to $mbox (should be $connection) in the pop3_list() function.]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值