打开电子邮件由php使用imap给我这个错误消息:imap_open()[function.imap-open]:无法打开流{imap.gmail.com:993/imap/ssl}INBOX [英] open email by php using imap giving me this error Message: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX

查看:1281
本文介绍了打开电子邮件由php使用imap给我这个错误消息:imap_open()[function.imap-open]:无法打开流{imap.gmail.com:993/imap/ssl}INBOX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用imap方法通过php打开电子邮件,但它给我一个错误无法打开流{imap.gmail.com:993/imap/ssl}INBOX,这是我的代码

I am trying to open the email messages by php using imap method but it give me an error Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX and this is my code

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'nohamedtemraz92@gmail.com';
$password = '0129799169mohamed';

/* try to connect */
$inbox = imap_open($hostname,$username ,$password) or die('Cannot connect to Gmail: '        imap_last_error());

    /* grab emails */
    $emails = imap_search($inbox,'ALL');

    /* if emails are returned, cycle through each... */
    if($emails) {

        /* begin output var */
        $output = '';

        /* 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);


            $output.= 'Name:  '.$overview[0]->from.'</br>';
                $output.= 'Email:  '.$overview[0]->message_id.'</br>';



        }

        echo $output;
    } 

 /* close the connection */
imap_close($inbox);


推荐答案

{imap.gmail.com:993/imap/ssl}INBOX

访问安全性较低的应用的帐户安全性,或者您可以尝试生效的电子邮件帐户

working for me but you have to enable 'Access for less secure apps' on account security or you can try live email account

这篇关于打开电子邮件由php使用imap给我这个错误消息:imap_open()[function.imap-open]:无法打开流{imap.gmail.com:993/imap/ssl}INBOX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆