473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

email to trigger php function

How can a POP3 email address execute a script?
Someone sends an email to so**************@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
Jul 17 '05 #1
3 7340
"Will Paris" <wi***********@sbcglobal.net> wrote in message
news:3y**********************@newssvr28.news.prodi gy.com...
How can a POP3 email address execute a script?
Someone sends an email to so**************@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

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:

so*******@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

Jul 17 '05 #2
On 2004-01-09, CountScubula <me@scantek.hotmail.com> wrote:
"Will Paris" <wi***********@sbcglobal.net> wrote in message
news:3y**********************@newssvr28.news.prodi gy.com...
How can a POP3 email address execute a script?
Someone sends an email to so**************@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

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:

so*******@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);
?>

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

# forward mail that is sent to ma*********@foo.example
# to everybody that is in addresses.txt
:0
* ^TO_mailinglist@foo\.example$
! `cat addresses.txt`
--
http://home.mysth.be/~timvw
Jul 17 '05 #3
*** 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 so**************@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
--
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Josué Maldonado | last post by:
Hello list, The TCL trigger that uses NEW and OLD arrays failed after after I removed a unused column, now I got this error: pltcl: Cache lookup for attribute '........pg.dropped.24........'...
0
by: JohnO | last post by:
Thanks to Serge and MarkB for recent tips and suggestions. Ive rolled together a few stored procedures to assist with creating audit triggers automagically. Hope someone finds this as useful as...
2
by: Chris Gamache | last post by:
Tsearch2 comes with its own tsearch2 trigger function. You pass column names to it, and it puts a vanilla tsvector into the column named in TG_ARGV. Not only can you pass column names to it, but...
2
by: Karl O. Pinc | last post by:
I'm sure I saw something like this on the postgresql web site but the the search function is down in the documentation area. I'm unable to pass a function arguments in a CREATE TRIGGER...
5
by: Peter Erickson | last post by:
I am running postgresql 7.4.2 and having problems creating a trigger function properly. I keep getting the following error: ERROR: OLD used in query that is not in rule I have a table called...
0
by: Bob | last post by:
Hi, I have a very odd postgresql problem. I have some subqueries contained within a function which are looking for unrefernced data and then delete any rows that are found: CREATE OR...
1
by: Vams | last post by:
Everyone, I need your help, I am trying to pass a parameter to a function that is to be called by a trigger. But, the correct function isn't being recognized and I am getting an error stating...
4
by: Együd Csaba | last post by:
Hi, I created a trigger function and a trigger with that function on a table. It is an "after insert or update or delete" trigger, in which I want to modify a second table regardless of the...
8
by: Frank van Vugt | last post by:
Hi, If during a transaction a number of deferred triggers are fired, what will be their execution order upon the commit? Will they be executed in order of firing or alfabetically or...
5
by: Bruno Rafael Moreira de Barros | last post by:
function test1() { trigger_error('My error'); } application.php //code... test1(); //code...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.