English 中文(简体)
无法从使用 php的电子邮件箱中获取
原标题:Unable to get inbox from gmail using php imap
  • 时间:2023-12-21 09:26:36
  •  标签:
  • php
  • php-imap

Hello guys正在试图利用Sphp来获取电子邮件信息,但正在获得。 网络互不兼容错误

这是我的法典。

<h1>Gmail Email Inbox using PHP with IMAP</h1>
<?php
    if (! function_exists( imap_open )) {
        echo "IMAP is not configured.";
        exit();
    } else {
        ?>
<div id="listData" class="list-form-container">
    <?php
        
        /* Connecting Gmail server with IMAP */
        $connection = imap_open( {imap.gmail.com:993/imap/ssl}INBOX ,  My correct email address here ,  My correct password here ) or die( Cannot connect to Gmail:   . imap_last_error());
        
        /* Search Emails having the specified keyword in the email subject */
        $emailData = imap_search($connection,  SUBJECT "Article " );
        
        if (! empty($emailData)) {
            ?>
    <table>
        <?php
            foreach ($emailData as $emailIdent) {
                
                $overview = imap_fetch_overview($connection, $emailIdent, 0);
                $message = imap_fetchbody($connection, $emailIdent,  1.1 );
                $messageExcerpt = substr($message, 0, 150);
                $partialMessage = trim(quoted_printable_decode($messageExcerpt)); 
                $date = date("d F, Y", strtotime($overview[0]->date));
                ?>
        <tr>
            <td><span class="column">
                    <?php echo $overview[0]->from; ?>
            </span></td>
            <td class="content-div"><span class="column">
                    <?php echo $overview[0]->subject; ?> - <?php echo $partialMessage; ?>
            </span><span class="date">
                    <?php echo $date; ?>
            </span></td>
        </tr>
        <?php
            } // End foreach
            ?>
    </table>
    <?php
        } // end if
        
        imap_close($connection);
    }
    ?>
</div>

Am supposed to get emails from my gmail account and display them in the html as seen in the code above. Please guys let s show some love.

最佳回答

问题完全不是我的法典,而是最初说是无法做到的,而是建立在封闭港口993的基础之上。 证明错误和认证失败无效。 这在Gmail s end。 我不知道,如果转而使用较少的附担保,那么问题就会得到解决,我也找不到。 我指的是Gmail不支持用简单文本作为电子邮件和密码认证。 他们使用UNTH,如果你把你与Gmail 你的 mu子连接起来,则Gmail会打上连接。 我在多次尝试之后发现了这一点。 希望有助于其他受挫的用户。 如果你需要获得电子邮件,则使用OAuth,在我的案件中进行罚款。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...