By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,967 Members | 2,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,967 IT Pros & Developers. It's quick & easy.

Script that receives email message and responds depending on content

P: n/a
The subject line is a little too general. I would like you to tell me
about scripts that can receive email messages and call other scripts
depending on the content of these messages.

Thanks!
Jan 2 '08 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Bill Bell wrote:
The subject line is a little too general. I would like you to tell me
about scripts that can receive email messages and call other scripts
depending on the content of these messages.

Thanks!
I have implemented such a thing as a daemon that periodically parses a
mailbox on the local server and does various things with the content of
the messages (processing meta tags inside the message, archiving
attachments to NAS, etc). Let me first say that while it is entirely
possible to do this in PHP, it is probably not the best choice (my
opinion, of course).

If you're more specific about what you are trying to do, you'll probably
get better answers. For example, can your script sit on the same
machine as the mail server, or do you need to use IMAP to retrieve the
messages (which is far more complicated)? Will the process be initiated
manually, or periodically, or will it always be running? What sort of
things do you intend to do with the information in the messages?

Jeremy
Jan 2 '08 #2

P: n/a
On Wed, 02 Jan 2008 23:07:28 +0100, Jeremy <je****@pinacol.comwrote:
Bill Bell wrote:
>The subject line is a little too general. I would like you to tell me
about scripts that can receive email messages and call other scripts
depending on the content of these messages.
Thanks!

I have implemented such a thing as a daemon that periodically parses a
mailbox on the local server and does various things with the content of
the messages (processing meta tags inside the message, archiving
attachments to NAS, etc). Let me first say that while it is entirely
possible to do this in PHP, it is probably not the best choice (my
opinion, of course).

If you're more specific about what you are trying to do, you'll probably
get better answers. For example, can your script sit on the same
machine as the mail server, or do you need to use IMAP to retrieve the
messages (which is far more complicated)? Will the process be initiated
manually, or periodically, or will it always be running? What sort of
things do you intend to do with the information in the messages?
There are perl scripts that I know of (mainly in trouble ticket systems)
that ARE the application that recieves the mail, instead of a cronjob
inbox poller. Requires some more access to the server then just some
shared hosting though.
--
Rik Wasmus
Jan 2 '08 #3

P: n/a
On Jan 2, 4:56 pm, Bill Bell <Bell....@gmail.comwrote:
The subject line is a little too general. I would like you to tell me
about scripts that can receive email messages and call other scripts
depending on the content of these messages.

Thanks!
Install Procmail
Configure .procmailrc to pipe incoming mail to a script which parses
the content
you are looking for and take appropriate actions (such as calling
other scripts,
updating a database, etc.)

I use perl to do it, although I imagine you could use php as well.

faulkes
Jan 2 '08 #4

P: n/a
On Wed, 2 Jan 2008 15:52:21 -0800 (PST), faulkes
<mi*************@gmail.comwrote:
>I use perl to do it, although I imagine you could use php as well.
PHP works fine but, on our LAMP setup at least, you need to run PHP as
a CGI I think.
#!/opt/php5/bin/php
as the first line of your script.

Then I read in the Email like this:
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

and process.
--
Locate your Mobile phone: <http://www.bizorg.co.uk/news.html>
Great gifts: <http://www.ThisBritain.com/ASOS_popup.html>
Jan 3 '08 #5

P: n/a
On Jan 2, 5:07 pm, Jeremy <jer...@pinacol.comwrote, in part:
I have implemented such a thing as a daemon that periodically parses a
mailbox on the local server and ...
Thanks for this, Jeremy. It hadn't occurred to me to use the fact that
there would be just one receiving mailbox that I could get at.
If you're more specific about what you are trying to do, you'll probably
get better answers. For example, can your script sit on the same
machine as the mail server, or do you need to use IMAP to retrieve the
messages (which is far more complicated)? Will the process be initiated
manually, or periodically, or will it always be running? What sort of
things do you intend to do with the information in the messages?
Some years ago I built a PHP site for a local group of employment
counselling agencies. They are not adept at using computer interfaces,
and my efforts to improve this site's interface have not proven
adequate. So I want to take a different tack.

What happens with the current interface is that users fail to identify
themselves by selecting from a drop-down list. I want to replace the
current system with one in which individuals email messages intended
for everyone to a distinct address on the site's domain. (In this way
they are obliged to identify themselves as individuals, and I can work
out authentication once I get over the current hurdle.) When software
running on the server that hosts this mailbox notices the presence of
a message it is to obtain the contents of the message and the sender's
email address, and arrange to send the message to all of the agencies
using the sender's address.

Bill
Jan 3 '08 #6

P: n/a
On Jan 2, 6:09 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote, in
part:
There are perl scripts that I know of (mainly in trouble ticket systems)
that ARE the application that recieves the mail, instead of a cronjob
inbox poller. Requires some more access to the server then just some
shared hosting though.
--
Rik Wasmus

Thanks, Rik. Although I work in Python I used to be able to read and
write Perl. Would you happen to have the URL for a sample, please?

Bill
Jan 3 '08 #7

P: n/a
On Jan 2, 6:52 pm, faulkes <michael.behr...@gmail.comwrote, in part:
Install Procmail
Configure .procmailrc to pipe incoming mail to a script which parses
the content
you are looking for and take appropriate actions (such as calling
other scripts,
updating a database, etc.)
Thanks, Michael. I'll take a look at procmail.

Bill

Jan 3 '08 #8

P: n/a
On Jan 3, 2:42 am, David Quinton
<usenet_2005D_em...@REMOVETHISBITbizorg.co.ukwrote , in part:
PHP works fine but, on our LAMP setup at least, you need to run PHP as
a CGI I think.
Thanks, David. I'm not sure I can run PHP as a CGI. However, I will
bear this in mind.

Bill
Jan 3 '08 #9

P: n/a
Bill Bell wrote:
On Jan 2, 5:07 pm, Jeremy <jer...@pinacol.comwrote, in part:
>I have implemented such a thing as a daemon that periodically parses a
mailbox on the local server and ...

Thanks for this, Jeremy. It hadn't occurred to me to use the fact that
there would be just one receiving mailbox that I could get at.
>If you're more specific about what you are trying to do, you'll probably
get better answers. For example, can your script sit on the same
machine as the mail server, or do you need to use IMAP to retrieve the
messages (which is far more complicated)? Will the process be initiated
manually, or periodically, or will it always be running? What sort of
things do you intend to do with the information in the messages?

Some years ago I built a PHP site for a local group of employment
counselling agencies. They are not adept at using computer interfaces,
and my efforts to improve this site's interface have not proven
adequate. So I want to take a different tack.

What happens with the current interface is that users fail to identify
themselves by selecting from a drop-down list. I want to replace the
current system with one in which individuals email messages intended
for everyone to a distinct address on the site's domain. (In this way
they are obliged to identify themselves as individuals, and I can work
out authentication once I get over the current hurdle.) When software
running on the server that hosts this mailbox notices the presence of
a message it is to obtain the contents of the message and the sender's
email address, and arrange to send the message to all of the agencies
using the sender's address.

Bill
Bill,

Actually, I would think this would be better done in the MTA. Every one
I know of has the ability to have email lists. Why reinvent the wheel?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 3 '08 #10

P: n/a
On Jan 3, 1:16 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Actually, I would think this would be better done in the MTA. Every one
I know of has the ability to have email lists. Why reinvent the wheel?
The answer to that question in my case, Jerry, is that I didn't know
much about wheels. ;-)

I'll think about this idea for sure.

Bill
Jan 3 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.