0

我试图弄清楚如何使用fetchmail将电子邮件转发(或管道)到 PHP 脚本。我从来没有这样做过,甚至不确定我是否走在正确的轨道上。从我读过的内容来看,我认为我需要使用 MDA 来转发邮件。我使用procmail作为我的 MDA。

这是我的 fetcmailrc 文件

set daemon 150
set logfile /local/web/sites/sitename/mail/fetchmail.log
poll blahblah with proto IMAP
user Username there with password userpassword is Username here
ssl
fetchall
no rewrite
mda "/usr/bin/procmail -d Username -f %F -d %T $HOME/.procmailrc";

这是我的 procmailrc 文件。您可以在底部看到我正在尝试将电子邮件传输到 PHP 脚本。

SHELL=/bin/csh
DEFAULT=/var/mail/Username/ 
MAILDIR=/var/mail/Username/    

:0
! `/usr/local/bin/php -f /local/web/sites/stack/htdocs/bin/catchmail.php`

我运行 fetchmail 并且转发(到 PHP 的管道)不起作用。我的 fetchmail.log 说:

procmail:  Insufficient prvileges
procmail:  Unknown user

任何指针?我是否朝着正确的方向前进?

4

1 回答 1

1

You are not piping to PHP, you are sending email to the address that your PHP script outputs. You probably want to change the exclamation mark (!) to a pipe (|) in order for the recipe to do what you describe.

The error message from Procmail indicates that you are invoking it incorrectly, or that it lacks a setuid bit or something like that. I'm no Fetchmail expert but the mda line looks fishy -- you hardly want two conflicting -d flags at the very least. Maybe that's the problem right there. The path to the .procmailrc will be deduced by Procmail with the -d option. Try with something simpler, like this:

mda "/usr/bin/procmail -f %F -d %T"

By the way, the assignment SHELL=/bin/csh seems really out of line. In my experience, attempting to use csh or tcsh with Procmail simply doesn't work. (Anyway, read Csh Programming Considered Harmful.) If you know exactly what you are doing, please explain why you have it there. Otherwise, take it out before you do anything else.

于 2012-05-22T07:36:10.440 回答