Yes, yes, it's entirely possible with Perl.
There are two options. You could write a simple daemon (to run at all times) to monitor a POP email account. Or you could have a script run at scheduled times (via crontab) to do the same thing.
If a certain email message is detected, you can do whatever your soul wishes, really. There's a number of modules that you could find on
CPAN that will help you check a POP account from your script, parse messages, etc.
Your script may look as simple as this (read inline comments for more info):
use Mail::POP3Client;
$pop = new Mail::POP3Client( USER => "me",
PASSWORD => "mypassword",
HOST => "pop3.do.main" );
my $specific_email_subject = "Parse by script";
my $parser_script = "email_parse.pl";
for ($i = 1; $i <= $pop->Count(); $i++) {
foreach ( $pop->Head($i) ) {
if (/^Subject:\s+($specific_email_subject)/i) {
# Special email detected!!!
# open a 'pipe' to the script that will parse/process
# this email message body.
open(PARSER,">$parser_script |");
# send email body to the script (will receive
# it via STDIN
print PARSER $pop->Body($i);
# close pipe (end 'transmission')
close(PARSER);
}
}
}
(note: not tested).
UPDATE: added the sample script.
_____________________
signature is under repair
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.