使用 imap 访问电子邮件 [英] Access emails using imap

查看:62
本文介绍了使用 imap 访问电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 14.02 上使用 Apache 并在其上运行 php.我已连接到远程 mssql 服务器,因此不需要 mysql .

I am using Apache on Ubuntu 14.02 and running php on the same.I have connected to a remote mssql server hence no need of mysql .

我想知道如何连接到在 gmail 中注册的电子邮件 ID 以阅读收到的电子邮件.

I want to know how to connect to an email id registered with gmail in order to read the incoming emails .

我已经尝试了下面的方法,但它在从我的本地主机运行时显示一个空白屏幕:

I have tried the below , but it shows a blank screen while running it from my localhost :

<?php

error_reporting('E_ALL');
$mailboxPath = "{imap.gmail.com:993/imap/ssl}INBOX";
$username = "my_email@gmail.com";
$password = "mypassword";
$imap = imap_open($mailboxPath, $username, $password);
print_r($imap);

?>

我在运行程序时插入了我的实际 gmail 用户名和密码.我想知道我是否遗漏了什么.

I am inserting my actual gmail username and password while running the program . I want to know if i am missing something .

非常感谢

推荐答案

解决方案如下:

  1. 登录您的 gmail 帐户,启用 imap.

  1. Login to your gmail account, enable imap.

先让访问这里:https://www.google.com/settings/security/lesssecureapps

转到:https://accounts.google.com/b/0/DisplayUnlockCaptcha并启用访问.

就是这样.

当我尝试在 php 上使用 imap 接收电子邮件时,我遇到了完全相同的问题.我正在运行完全相同的脚本,我知道它适用于我的其他 gmail.

I had the exact same problem when I try to get emails with imap on php. I was running the exact same script that I know it works with my other gmail.

解决方案如上,错误信息为:

The solution is above and the error message was:

错误:无法向 IMAP 服务器进行身份验证:[ALERT] 请通过您的网络浏览器登录

ERROR: Can not authenticate to IMAP server: [ALERT] Please log in via your web browser

这篇关于使用 imap 访问电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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