Login
网站首页 > 文章中心 > 其它

php的imap库_php imap

作者:小编 更新时间:2023-10-10 19:52:25 浏览量:382人看过

如何扩展PHP的IMAP模块

如果对php进行模块扩展,重新编译PHP,这个过程比较痛苦,我的方法都是采用编译模块为*.so的方式,简单,方便,不用去其他地方找模块源码包,php源码自带了.

①.、进入安装目录

cd /path/ext/imap

/usr/local/webserver/php/bin/phpize

./configure --with-php-config=/usr/local/webserver/php/bin/php-config

就是到这步报错了,如果你碰到这样的错误:

This c-client library is built with Kerberos support.

Add --with-kerberos to your configure line. Check config.log for details

yum -y install libc-client-*

安装完毕后,再次编译,

这次的错误不一样,如下:

configure: error: Kerberos libraries not found.

Check the path given to --with-kerberos (if no path is given, searches in /usr/kerberos, /usr/local and /usr )

既然提示少参数,就加上该参数吧,

./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-kerberos=/usr

This c-client library is built with SSL support

看来离希望越来越近了,于是就加上 --with-imap-ssl=/usr 参数,终于编译通过了,真不容易.

最后完整的编译 imap 模块参数如下:

./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-kerberos=/usr --with-imap-ssl=/usr

make

make install

如何用PHP里的IMAP函数,实现邮件的发送,希

//以腾讯企业邮箱做了测试

$mailServer="imap.exmail.qq.com";?//IMAP主机

$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);?//获取信件正文

}

/**

*

*?匹配提取信件头部信息

*?@param?String?$str

*/

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;

php IMAP读取邮件信息

php

$emails = imap_search($mbox,'ALL');

if($emails) {

rsort($emails);

foreach($emails as $email_number) {

$overview = imap_fetch_overview($mbox,$email_number,0);

$pos = explode('@',$overview[0]-from);

$phone = substr($pos[0],-11); // 发件人手机号码

$struct = imap_fetchstructure($mbox, $email_number);

print_r($struct);

$parts = $struct-parts;

$i = 0;

if (!$parts) { /* Simple message, only 1 piece */

$attachment = array(); /* No attachments */

$content = imap_body($mbox, $email_number);

} else { /* Complicated message, multiple parts */

$endwhile = false; $stack = array(); /* Stack while parsing message */

$content = ""; /* Content of message */

$attachment = array(); /* Attachments */ while (!$endwhile) {

if (!$parts[$i]) {

if (count($stack) 0) {

$parts = $stack[count($stack)-1]["p"];

$i = $stack[count($stack)-1]["i"] ◆ 1;

array_pop($stack);

} else {

$endwhile = true;

if (!$endwhile) {

$partstring = "";

foreach ($stack as $s) {

$partstring .= ($s["i"]◆1) . ".";

$partstring .= ($i◆1);

$file_data = imap_fetchbody($mbox, $email_number, $partstring);

$attachment[] = array("filename" =$parts[$i]-parameters[0]-value,

"filedata" = $file_data

if($parts[$i]-subtype == 'JPEG')

{

}elseif($parts[$i]-subtype == 'GIF'){

}elseif($parts[$i]-subtype == 'PLAIN'){

if ($parts[$i]-parts) {

$stack[] = array("p" = $parts, "i" = $i);

$parts = $parts[$i]-parts;

$i◆◆;

} /* while */

} /* complicated message */

echo "userphone $phone, result:

";

echo "Content: $content

echo "Attachments:"; var_dump($attachment);

echo "br/br/---------------------------------------------------------------------br/br/";

echo "br/br/---------------------------------------------------------------------br/br/";

echo "br/br/---------------------------------------------------------------------br/br/";

imap_close($mbox);

PHP的IMAP交换问题问题,怎么解决

用get_extension_funcs("imap"); 函数进行测试,若返回boolean值为空,说明php_imap.dll文件没有加载进去!

PHP加载IMAP模块问题

extension_loaded("imap");

用get_extension_funcs("imap"); 函数进行测试,若返回boolean值为空,说明php_imap.dll文件没有加载进去,

php编译安装后如何安装IMAP扩展

今天程序员在最近实施的项目中需要增加IMAP验证,今天历史原因,公司很多服务器的linux操作系统及各应用程序版本都不一样,安装路径也很杂乱,再加上刚接手服务器不久,导致今天在安装IMAP的PHP扩展时,走了很多弯路;帮把今天的操作经理写下来供大家参考学习及备忘之.

环境:

Distributor ID: RedHatEnterpriseServer

Codename: Tikanga

再使用phpinfo.php 查看PHP相关信息后,开始安装php-imap,步骤如下:

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --with-kerberos --with-imap-ssl

最后 重启 apache 服务搞定!

注:上面的路径是本台服务器的相关路径,其它的服务器需要根据您的实际情况进行更改,理解整个部署的思路即可哈!

以上就是土嘎嘎小编为大家整理的php的imap库相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章