Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

email to trigger php function

0 views
Skip to first unread message

Will Paris

unread,
Jan 8, 2004, 8:33:51 PM1/8/04
to
How can a POP3 email address execute a script?
Someone sends an email to somePHPf...@mydomain.com and that email
parses subject and message and sender and executes somePHPfunctions() in a
script(possibly in somePHPfunctions.php). Is this a cron issue or an apache
issue? Curious as to if it can be done.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/04


CountScubula

unread,
Jan 8, 2004, 9:19:38 PM1/8/04
to
"Will Paris" <willpa...@sbcglobal.net> wrote in message
news:3ynLb.22901$P%1.218...@newssvr28.news.prodigy.com...


Do this: (i know guys, there are other ways to do it with procmailrc, but
most people mess that file up)

in /etc/mail/virtusertable:

some...@somedomain.com aliasScriptName


then in /etc/alaises

aliasScriptName "| /etc/smrsh/scriptname"

then in /etc/smrsh/scriptname

#!/usr/bin/php -q
<?php
// read from stdin
$fd = fopen("php://stdin", "r");
while (!feof($fd))
{
$inData = fgets($fd, 1024);
$inData = trim($inData);

.. proccess $inData here ...

}
fclose($fd);
?>

--
Mike Bradley
http://www.gzentools.com -- free online php tools

Tim Van Wassenhove

unread,
Jan 9, 2004, 1:27:11 AM1/9/04
to


Thats a lot of work :P
Following in procmailrc would satisfy:

# forward mail that is sent to maili...@foo.example
# to everybody that is in addresses.txt
:0
* ^TO_mailinglist@foo\.example$
! `cat addresses.txt`


--
http://home.mysth.be/~timvw

Alvaro G Vicario

unread,
Jan 9, 2004, 6:13:50 AM1/9/04
to
*** Will Paris wrote/escribió (Fri, 09 Jan 2004 01:33:51 GMT):
> How can a POP3 email address execute a script?
> Someone sends an email to somePHPf...@mydomain.com and that email
> parses subject and message and sender and executes somePHPfunctions() in a
> script(possibly in somePHPfunctions.php). Is this a cron issue or an apache
> issue?

It's a mail server (MTA) issue. In postfix:

Add this to /etc/postfix/aliases:

somePHPfunctions: |/path/to/scripts/somePHPfunctions.php

Then reload service. Please note somePHPfunctions.php should be a valid shell script:

#!/usr/bin/php -q

<?
.......
?>

Otherwise, I suppose you can call it with /usr/bin/php -q /path/to/scripts/somePHPfunctions.php

--
--
-- Álvaro G. Vicario - Burgos, Spain
--

0 new messages