extension_loaded("imap");
用get_extension_funcs("imap"); 函数进行测试,若返回boolean值为空,说明php_imap.dll文件没有加载进去,
如果对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
用get_extension_funcs("imap"); 函数进行测试,若返回boolean值为空,说明php_imap.dll文件没有加载进去!
今天程序员在最近实施的项目中需要增加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 服务搞定!
注:上面的路径是本台服务器的相关路径,其它的服务器需要根据您的实际情况进行更改,理解整个部署的思路即可哈!
//以腾讯企业邮箱做了测试
$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;
sae发邮件,使用sae的服务,平时的代码不可用,相当于使用接口来发
SAE邮件class , 目前只支持SMTP.
为保证您Email帐号安全,建议您注册新的专用于sae邮件发送的email,而不要使用自己日常的email.
php
$mail?=?new?SaeMail();
$mail-setAttach(?array("my_photo.jpg"?=?"照片的二进制数据"?));
$mail-quickSend(?
"to@sina.cn"?,
"邮件标题"?,
"邮件内容"?,
"smtpaccount@gmail.com"?,
"password"?
$mail-clean();?
//?重用此对象
$mail-quickSend(
"邮件内容"?,?
"smtpaccount@unknown.com"?,
"password"?,
"smtp.unknown.com"?,
);?//?指定smtp和端口
以上就是土嘎嘎小编为大家整理的php使用imap相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!