帮助使用 php 读取 gmail 消息
我需要从 gmail 读取电子邮件,但无法连接到 gmail pop3 服务器。 有人能帮我一下吗 ?
这里是代码:
$pop3 = new POP3;
$pop3->server = 'pop.gmail.com';
$pop3->user = 'username';
$pop3->passwd = 'password';
$pop3->debug = true;
$pop3->pop3_connect()
结果:
Warning: fsockopen() [function.fsockopen]: unable to connect to pop.gmail.com:110 (Connection timed out) in /public_html/cron/pop3.php on line 64
谢谢
I need to read emails from gmail but i cant connect to gmail pop3 server.
Can anyone help me here ?
Here the code:
$pop3 = new POP3;
$pop3->server = 'pop.gmail.com';
$pop3->user = 'username';
$pop3->passwd = 'password';
$pop3->debug = true;
$pop3->pop3_connect()
The result:
Warning: fsockopen() [function.fsockopen]: unable to connect to pop.gmail.com:110 (Connection timed out) in /public_html/cron/pop3.php on line 64
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据此页面(使用 Outlook Express 连接到 Gmail) ,您必须使用995端口进行POP3访问Gmail,并且必须启用SSL。
维基百科还声明了这一点:
According to this page (connecting to Gmail using Outlook Express), you have to use port 995 for POP3 access to Gmail, and furthermore, SSL must be enabled.
Wikipedia also states this:
我不确定它是否对您有帮助,但 GMAIL 有一个 ATOM Feed。 我使用 CURL 编写了一个 PHP 脚本来下载 Atom Feed,这样我就可以在只支持非常简单的 HTML 的过时手机上查看电子邮件。 因此,根据您想要执行的操作,下载和处理 ATOM 源可能比连接到 POP 服务器更容易。
I'm not sure if it will help you, but GMAIL has an ATOM feed. I wrote a PHP script to download the Atom Feed, using CURL, so that I could check my email on my antiquated cell phone that only supported very simple HTML. So, depending on what you want to do, it might be easier to download and process the ATOM feed than it is to connect to the POP server.
我不知道你正在使用什么类 - 但例如,使用 Daniel Lemos 的 包如下所示。 关键是选择正确的端口 (995) 和正确的加密方法(对于您使用的任何 pop3 包,TLS 设置为 true)。 例如,您可以使用如下所示的内容来启动连接。 不太喜欢这个类的架构或示例代码(大量嵌套的 if 语句),但它完成了工作。
I don't know what class you're using -- but for instance, using Daniel Lemos' package is shown below. The key is choosing the right port (995), and the right encryption method (TLS set to true for whatever pop3 package you are using). For example, you could use something like the below to initiate the connection. Not a big fan of how this class is architected, or the sample code (lot of nested if statements), but it does the job.
我认为您的电子邮件有两个简单的选择:
像 Kibbee 所说的 Cron 原子提要。 但是,在发送消息和获取消息之间会有一点延迟。
使用 http://smtp2web.com/ 将您的电子邮件发布到您的网站,这意味着要短得多延迟。 当然隐私不应该是至关重要的,因为您的邮件将通过中间层。
I think there are two easy options to your email:
Cron atom feed like Kibbee says. But then you will have a little delay between when message was sent and when you fetch it.
Use http://smtp2web.com/ which will post your email to your website which means a lot shorter delay. Offcourse privacy should not be crucial, because your mail will pass through intermediate.