0

所以,基本上我有 PHP imap_open 代码(idk 如何调用它),当您使用特定的电子邮件地址登录时,它可以工作。我想要做的是使用邮件服务器的根用户登录(我猜这就是它的名称,它是托管服务提供商在订购时给我的帐户)并检索任何电子邮件地址的收件箱。

这样做的目的是我想制作一个在线电子邮件客户端,人们可以在使用与邮件服务器无关的自定义身份验证系统登录时使用它(并且每个用户在数据库中都有他的电子邮件地址)。

我考虑过在数据库中保存电子邮件地址的加密密码,并使用它来登录个人电子邮件地址,但我不喜欢这个想法。

我想知道这是否可能,以及关于如何通过安全保存每封电子邮件的密码来解决问题的任何想法。

PS我确实设法使用root帐户使用SMTP PHPMailer从邮件服务器上的任何地址发送电子邮件。

我知道我不擅长解释事情,对此感到抱歉,并在此先感谢。

我目前正在使用此代码获取使用特定电子邮件地址密码的电子邮件地址的收件箱。

            $inbox = imap_open('{mail.example.com:993/imap/ssl}INBOX', 'user@example.com', 'password');
            /* 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>';

                        $body = imap_fetchbody($inbox, $email_number, 0);
                    $output.= 'Head: '.$body.'</br>';

                    $body = imap_fetchbody($inbox, $email_number, 1);
                    $output.= 'Body: '.$body.'</br>';


                    break;
                }

                echo $output;
            } 
            /* close the connection */
            imap_close($inbox);
4

0 回答 0