Script that receives email message and responds depending on content
Script that receives email message and responds depending on content
am 02.01.2008 22:56:01 von Bill Bell
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!
Re: Script that receives email message and responds depending oncontent
am 02.01.2008 23:07:28 von Jeremy
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
Re: Script that receives email message and responds depending on content
am 03.01.2008 00:09:31 von luiheidsgoeroe
On Wed, 02 Jan 2008 23:07:28 +0100, Jeremy wrote:
> 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
Re: Script that receives email message and responds depending on
am 03.01.2008 00:52:21 von faulkes
On Jan 2, 4:56 pm, 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!
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
Re: Script that receives email message and responds depending on content
am 03.01.2008 08:42:59 von David Quinton
On Wed, 2 Jan 2008 15:52:21 -0800 (PST), faulkes
wrote:
>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:
Great gifts:
Re: Script that receives email message and responds depending on
am 03.01.2008 17:17:24 von Bill Bell
On Jan 2, 5:07 pm, Jeremy wrote, 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
Re: Script that receives email message and responds depending on
am 03.01.2008 17:19:41 von Bill Bell
On Jan 2, 6:09 pm, "Rik Wasmus" wrote, 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
Re: Script that receives email message and responds depending on
am 03.01.2008 17:21:42 von Bill Bell
On Jan 2, 6:52 pm, faulkes wrote, 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
Re: Script that receives email message and responds depending on
am 03.01.2008 17:23:22 von Bill Bell
On Jan 3, 2:42 am, David Quinton
wrote, 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
Re: Script that receives email message and responds depending on content
am 03.01.2008 19:16:40 von Jerry Stuckle
Bill Bell wrote:
> On Jan 2, 5:07 pm, Jeremy wrote, 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.
jstucklex@attglobal.net
==================
Re: Script that receives email message and responds depending on
am 03.01.2008 21:22:43 von Bill Bell
On Jan 3, 1:16 pm, Jerry Stuckle wrote:
> 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