473,509 Members | 11,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7341
"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
2122
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
2450
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
2546
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
5504
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
3936
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
1919
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
4590
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
1221
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
2602
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
2620
by: Bruno Rafael Moreira de Barros | last post by:
function test1() { trigger_error('My error'); } application.php //code... test1(); //code...
0
7237
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
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7074
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
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.