Push email to a apache/php server

我的未来我决定 提交于 2019-12-07 00:32:32
Jason Punyon

If you want to use postfix as your MTA you can alias an email address to any executable like this. It really isn't that difficult to setup on a *nix box...

I've no experience with IMAP, but had to do the same thing. If I were you, I'd install Postfix and use the pipe command (basically lets you run an arbitrary script) to invoke a small http client that parses the email and sends it to your server.

You can replace postfix with whatever MTA you'd like, of course. The point is: don't implement your own email server. Use an existing one and use its hooks to send the mail off to where ever it is you want, however it is you want.

Webrsk

email_scheduler.c

int main()
{
        while(1){
                        sleep(5); // every 5 secs the email_parser.php would get executed.
                        system("/usr/bin/php -q /var/www/html/email_parser.php");
        }
}

email_parser.php :

/* Use any email message parser to parse the email messages like MIME message parser based on your purpose : Refer : http://www.phpclasses.org/browse/package/3169.html */

Also check relevant answers here for more info

There's an old (but great) article on Evolt about piping emails to a php script, which therefore gets the full content of the email and can act on it.

http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/index.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!