每 15 秒左右使用 php 从收件箱读取电子邮件
我正在尝试找出一种使用 php 执行以下操作的方法:
让网站 (index.php) 每 15 秒左右检查一次电子邮件收件箱,阅读主题行和消息内容,然后在屏幕上显示该消息。这个想法是,它将在发送时将收件箱中的所有消息显示在index.php页面上。我猜每当有新消息来显示内容时,index.php页面也必须刷新。
谢谢!
I'm trying to figure out a way to do the following with php:
Have a website (index.php) check an e-mail inbox every 15 seconds or so, read the subject line, and the contents of the message, and then display that message on the screen. The idea being it will display all the messages in the inbox on the index.php page as they get sent in. And I guess the index.php page will also have to refresh whenever there is a new message to display the content.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为少于一分钟的间隔很难实现和/或运行起来相当昂贵。如果您需要这么高的频率,最好为邮件处理程序编写一个钩子,每当新邮件到达时就会触发该钩子。如何执行此操作取决于您的邮件处理程序。
I think an interval of less than a minute is rather difficult to realize and/or rather expensive to run. If you need that high a frequency, you should be better off by writing a hook for your mail handler that gets triggered whenever new mail arrives. How to do that depends on your mail handler.
将电子邮件内容转储到数据库或某种平面文件中,并使用其内容进行显示。
如果您使用 Gmail:
http://framework.zend.com/download/gdata
Dump the email contents into a database or some kind of flat file and use its contents to display.
If your using gmail:
http://framework.zend.com/download/gdata
坏主意。如果您的页面每 15 秒刷新一次,那么任何人都将无法单击任何内容,因为一旦页面刷新,它就会再次开始刷新。
您可能想要的是更加ajax 的东西,例如gmail 使用的东西。这会在后台进行刷新,因此页面本身不会刷新。有很多关于如何执行此操作的教程。例如 This,您可以推断出您想要的内容。
Bad idea. If your page refreshes every 15 seconds, nobody will ever be able to click on anything because as soon as the page refreshes, it will start refreshing again.
What you probably want is something more ajaxy, like gmail uses. This does the refresh in the background so the page itself doesn't refresh. There are lots of tutorials on how to do this. For example This, which you can extrapolate out to what you want.