电子邮件管道与php脚本 [英] Email piping with php script

查看:140
本文介绍了电子邮件管道与php脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转发所有的电子邮件(来到我的收件箱)到php脚本并检索电子邮件内容并保存在一个文件中。所以这样做,我正在添加电子邮件转发器与管道正确。



转发地址:tickets@ana.stage.centuryware.org



管道程序:/ home /centuryw/public_html/stage/ana/osticket/upload/api/pipe.php



我将以下脚本用作pipe.php

 #!/ usr / bin / php -q 
<?
/ *从STDIN * /
$ fd = fopen(php:// stdin,r)读取消息;
$ email =; //这将是保存数据的变量。
while(!feof($ fd)){
$ email。= fread($ fd,1024);
}
fclose($ fd);
/ *将数据保存到文件* /
$ fdw = fopen(mail.txt,w +);
fwrite($ fdw,$ email);
fclose($ fdw);
/ *脚本结束* /

但没有输出文件,所有电子邮件都被退回再次到我的收件箱任何人都可以帮助我吗?

解决方案

确保PHP文件具有执行位设置(即 chmod + x pipe.php )。


Hi' I want to forward all the emails(which are come to my inbox) to php script and retrieve email content and save it in a file. So do that I was add email forwarder with piping path correctly.

Address to Forward :tickets@ana.stage.centuryware.org

Pipe to a Program : /home/centuryw/public_html/stage/ana/osticket/upload/api/pipe.php

I have used following script as pipe.php

#!/usr/bin/php –q
<?
/* Read the message from STDIN */
$fd = fopen("php://stdin", "r");
$email = ""; // This will be the variable holding the data.
while (!feof($fd)) {
    $email .= fread($fd, 1024);
}
fclose($fd);
/* Saves the data into a file */
$fdw = fopen("mail.txt", "w+");
fwrite($fdw, $email);
fclose($fdw);
/* Script End */

But there was no output file and all email are bounced to my inbox again. Can anyone help me please?

解决方案

Make sure the PHP file has the execute bit set (i.e. chmod +x pipe.php).

这篇关于电子邮件管道与php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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