Not sure if you got a reply to this yet, but another option is to read the
mailbox via a cron job. I use this successfully. You can see an example here
( http://www.weberdev.com/get_example-4015.html )
bastien
From: "john@xxxxxxxxxxxxxxxxxxxx" <john@xxxxxxxxxxxxxxxxxxxx>
Reply-To: john@xxxxxxxxxxxxxxxxxxxx
To: php-db@xxxxxxxxxxxxx
Subject: Passing emails to php script
Date: Sun, 18 Feb 2007 12:05:01 +0000
I am trying to pass emails as they come in to a php script to parse. I
apologise in advance if this does not appear a database question, though I
will be using a database with it once I figure out the initial method of
getting the incoming email to the parsing script. If you think this
should go to another discussion group I will contritely go away.
I am on a shared server and have three options:
/mail account
Parsing messages directly by accessing them in the /mail directory (all
mail for the domain is stored there.). However, I don't think this will
work as it is unpredictable when they are deleted from the server ie when I
log on to my computer they are downloaded.
.procmail file
Or I could also manage filtering and handling using the .procmail file in
the root directory. Unfortunately, I don't have access to that file.
Adding a filter:
http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=32
I have tried to set up a filter in my server's control panel to pass all
messages to a program for processing (via |, a pipe). However, the script
does not seem to run in response to this.
In summary I have set up the filter to send incoming emails to a file
(/public_html/mailfilters/email.php), which is acknowledged in the cpanel
response when I test it, but the file should send me an email as its only
command but I don't get any email. The php file contents are below also,
it is a simple mail() test. So the first question is what might be wrong
here - why does the file not seem to execute, has it been reached by the
mail filter? I have asked the server support team but they say it is a
coding question. Is it significant that when sent a message with test in
the subject I get an error email back including this:
"A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
pipe to |/public_html/mailfilters/email.php
generated by john@xxxxxxxxxxxxxxxxxxxx
local delivery failed
"
The second question is what are the variable names for the input mail sent
by the mail filter, is it STDIN, the php constant, and is this an array, or
is there a way of knowing what the individual variable names are
representing the subject, body, from address etc?
mail.php:-
<?
mail("john@xxxxxxxxxxxxxxxxxxxx","anytext","anytext","From:john@xxxxxxxxxxxxxxxxxxxx");
?>
The filter is set up and I get this acknowledgement in response to a test
on the set up page:
*Filter Trace Results:*
Condition is true: $header_subject: contains test
Return-path copied from sender
Sender = shortsta@xxxxxxxxxxxxxxxxxxx
Recipient = shortsta@xxxxxxxxxxxxxxxxxxx
Testing Exim filter file "/etc/vfilters/shortstay-london.com"
Pipe message to: /public_html/mailfilters/email.php
*Filtering set up at least one significant delivery or other action.
**No other deliveries will occur.
*
I definitely have this file: /public_html/mailfilters/email.php.
Testing by sending an email to myself with test in the subject, I get a
return message:
"This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
pipe to |/public_html/mailfilters/email.php
generated by john@xxxxxxxxxxxxxxxxxxxx
local delivery failed
------ This is a copy of the message, including all the headers. ------
Return-path: <john@xxxxxxxxxxxxxxxxxxxx>
Received: from shortsta by box148.bluehost.com with local-bsmtp (Exim 4.63)
(envelope-from <john@xxxxxxxxxxxxxxxxxxxx>)
id 1HIXbm-00017Y-NC
for john@xxxxxxxxxxxxxxxxxxxx; Sat, 17 Feb 2007 15:00:49 -0700
X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on
box148.bluehost.com
X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00
autolearn=ham version=3.1.7
Received: from smtp803.mail.ird.yahoo.com ([217.146.188.63])
by box148.bluehost.com with smtp (Exim 4.63)
(envelope-from <john@xxxxxxxxxxxxxxxxxxxx>)
id 1HIXbm-00017P-Do
for john@xxxxxxxxxxxxxxxxxxxx; Sat, 17 Feb 2007 15:00:42 -0700
Received: (qmail 48251 invoked from network); 17 Feb 2007 22:00:41 -0000
Received: from unknown (HELO ?192.168.1.3?)
(ioannes@xxxxxxxxxxxxxx@81.158.50.3 with plain)
by smtp803.mail.ird.yahoo.com with SMTP; 17 Feb 2007 22:00:41 -0000
X-YMail-OSG:
mOKmmGAVM1kYlA.mjkBaa2_RtuLxhTh77Tbb41y1VQkB7oeisDh..4_lUjV8QebfQsR.uBqJ.Q.rps5NVKrZnnsO2QSutda_GLqjKvSosK8xXg--
Message-ID: <45D77B08.1010901@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 17 Feb 2007 22:00:40 +0000
From: "john@xxxxxxxxxxxxxxxxxxxx" <john@xxxxxxxxxxxxxxxxxxxx>
Reply-To: john@xxxxxxxxxxxxxxxxxxxx
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
To: john@xxxxxxxxxxxxxxxxxxxx
Subject: test
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
test
John "
Any help appreciated.
John
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________
Buy what you want when you want it on Sympatico / MSN Shopping
http://shopping.sympatico.msn.ca/content/shp/?ctId=2,ptnrid=176,ptnrdata=081805
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php