Sudden PHP Error “Warning: imap_open() [function.imap-open]: Couldn't open stream”

前端 未结 5 1939
忘掉有多难
忘掉有多难 2021-01-20 11:54

Okay, this code \'was\' working perfectly and then I started playing around with it in order to let others connect to their e-mails and as you do ran into a few open stream

5条回答
  •  臣服心动
    2021-01-20 12:30

    I have tried this an works perfectly fine for me

    $inbox = imap_open("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", 'username', 'password')
                 or die('Cannot connect to Gmail: ' . imap_last_error());
    
    $emails = imap_search($inbox,'All');
    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);
            $message = imap_fetchbody($inbox,$email_number,2);
            $header =  imap_header($inbox, $email_number); 
            echo "

    data

    "; echo "
    ";print_r($message);
            echo "

    Message

    "; echo "
    ";print_r($message);
            echo "

    header

    "; echo "
    ";print_r($message);
            $overview[0]->seen;
            $overview[0]->subject;
            $overview[0]->from;
            $overview[0]->date;
    
        }
    } 
    /* close the connection */
    imap_close($inbox);
    

提交回复
热议问题