在接收电子邮件时,如何实时解析邮件 [英] How do I parse emails in realtime as they are recieved

查看:185
本文介绍了在接收电子邮件时,如何实时解析邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要构建一个电子邮件解析脚本,它将解析将进入收件箱并将内容转储到数据库中的电子邮件,同时使用电子邮件解析详细信息的卷曲请求。

I need to build an email parsing script which would parse emails that would come into an inbox and dump the contents into a database, while at the same time make a curl request with details parsed from the email.

在这一刻,我非常坚持在收件箱中实时查看电子邮件实时解析部分。有没有办法设置触发器来做这样的事情?我在使用基于php的webmail客户端方面拥有丰富的经验,但是这似乎也是不同的。

At this moment I'm quite stuck on implementing the part on how to parse emails in realtime as they are recieved in the inbox. Is there a way to set triggers to do something like this? I've extensive experience with working with php based webmail clients but this seems different though.

如何做到这一点 - 我假设一个cron工作,要做到这一点,我都是耳朵。

How can this be accomplished - I am assuming a cron job but if theres another way to do so I'm all ears.

推荐答案

是的,有。
您可以将电子邮件管理到脚本。

Yes, there is. You can pipe emails to your scripts.

假设您正在使用cPanel,请按照步骤

Assuming you are using cPanel, follow this steps:


  • 登录到您的cPanel。

  • 点击邮件标签下的转发器图标。

  • 点击添加转发器按钮。

  • 填写转发地址并将您想要的邮件地址
    用于管理邮件。

  • 选择管道到程序并填写脚本
    的完整路径,该脚本将处理消息。

  • Log in to your cPanel.
  • Click on the Forwarders icon, under the Mail tab.
  • Click on the Add Forwarder button.
  • Fill in Address to Forward and put the mail address you would like to pipe the messages from.
  • Select Pipe to a Program and fill in the full path to the script which will handle the messages.

这里是一个邮件捕获器示例将收到的电子邮件发送到您的其他邮件(仅用于演示):

And here is a mail catcher example that sends received email to your other mail (just for demonstration):

#!/usr/bin/php -q
<?php

// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd))
{
    $email .= fread($fd, 1024);
}
fclose($fd);


mail('you@yoursite.com','From my email pipe!','"' . $email . '"');

?>

这篇关于在接收电子邮件时,如何实时解析邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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