【发布时间】:2015-01-20 13:24:55
【问题描述】:
是否可以从我自己的域邮件中获取电子邮件?我想获取收件箱,请帮忙,我现在正在使用 IMAP,但它给了我像
这样的 ssl 错误MAIL.enlighten-energy.net 证书失败:服务器名称与证书不匹配:/OU=Domain Control Validated/OU=PositiveSSL Wildcard/CN=*.justhost.com
function fetch_gmail_inbox()
{
$res=array();
/* connect to gmail */
$hostname = '{imap.enlighten-energy.net:143/imap}';
$username = 'abc@enlighten-energy.net';
$password = '*******';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox,'UNSEEN');
/* if emails are returned, cycle through each... */
if($emails) {
/* put the newest emails on top */
rsort($emails);
/* for every email... */
foreach($emails as $email_number) {
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = quoted_printable_decode(imap_fetchbody($inbox,$email_number,1));
$structure = imap_fetchstructure($inbox,$email_number);
if($structure->parts[0]->encoding == 3 ||$structure->encoding == 3 )
{
$message=imap_base64($message);
}
if($structure->parts[0]->encoding == 4 ||$structure->encoding == 4)
{
$message = imap_qprint($message);
}
$message2= quoted_printable_decode(imap_fetchbody($inbox,$email_number,0));
$date=explode(':',$message2);
$date2= date('d-m-Y h:i:s',strtotime($date[8].':00:00'));
if($overview[0]->subject=="USR:Site01_Comms Complete")
{
$res['date']=$date2;
$res['body']=$message;
}else
{
echo "not a correct mail";
}
}
return $res;
}
/* close the connection */
imap_close($inbox);
}
但它对我不起作用任何建议都会很明显。在此先感谢
【问题讨论】:
-
"不工作" = ?一些错误信息?
-
MAIL.enlighten-energy.net 的证书失败:服务器名称与证书不匹配:/OU=Domain Control Validated/OU=PositiveSSL Wildcard/CN=*.justhost.com
-
$hostname = '{mail.enlighten-energy.net:143/imap/novalidate-cert}INBOX';使用这个