PHP - 如何从pop3电子邮件帐户访问和检索重要数据? [英] PHP - How to access and retrieve important data from a pop3 email account?

查看:207
本文介绍了PHP - 如何从pop3电子邮件帐户访问和检索重要数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个php程序,它将检查主题行中有关键字的任何电子邮件的存在,然后它将检索电子邮件的内容并将其传递给变量。

I am trying to create a php program that will check for the presence of any emails with a keyword in the subject line, then it will retrieve the contents of the email and pass it to a variable.

任何人都可以向我提供一些有关如何实现这一目标的有用信息?

Can anyone provide me with some helpful information on how to accomplish this?

推荐答案

可以更好地使用imap协议,您可以尝试 PHP的imap功能

If you can use imap protocol better, you can try the imap functions of PHP

<?php
    $imap = imap_open("{mail.yourserver.com:143}INBOX", "username", "password");
    $message_count = imap_num_msg($imap);

    for ($i = 1; $i <= $message_count; ++$i) {
        $header = imap_header($imap, $i);
        if (preg_match('#keyword#',$header['subject'])) {
             $body = imap_body($imap, $i);
             // your action here
        }
    }

    imap_close($imap);
?> 

这篇关于PHP - 如何从pop3电子邮件帐户访问和检索重要数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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