View Full Version : automatically scanning the subjects of email while on the server
06-09-2003, 03:38 PM
I would like to write a program that will periodically scan through the subjects of emails that are on the server. I have been told this can be done with a cgi, but aside from that I have no idea of how to approach this. I would prefer to use a language like perl php, or if necessary c. Thanks alot.
06-17-2003, 03:04 AM
Well, to be perfectly honest with you I have no idea how a server stores emails before they're retrieved. I've never had the pleasure(?) of working with one. But if they're stored within a directory like any other file then you could use a combination of shell commands and regular expressions.
I threw this script together for a very basic site search engine a while ago... Feel free to look it over and make modifications. Maybe it'll help.
# search.pl - a simple CGI search engine
# Timothy Boronczyk May 7, 2003
# command-line: [usr@www]$ search.pl term
# calling from php-enabled page: system("search.pl $term");
# Returns: (with HTML formating)
# Your search for [term] resulted in the following matches:
# 1. Page Foo - description of page foo.
# 2. Page Bar - description of page bar.
# 3. Untitled - description of untitled page.
# 4. Page Baz - No description available.
$path = "./"; # path of files in which to search
$no_results = 0; # number of results found
$term = join(' ', @ARGV); # term for which to search
print "<p>Your search for <b>$term</b> resulted in the
foreach(@files = `ls -A $path`)
if (($page_content = `cat $path$_`) =~ /$term/i)
print "<li style=\"padding: 4px;\"><a href=\"$path$_\">";
if ($page_content =~ /<title>(.*)<\/title>/i)
print "</a><br />- ";
if ($page_content =~
/<meta name=[\'\"]description[\'\"] content=[\'\"](.*)[\'\"]/i)
print "No description available";
if ($no_results == 0)
print "</ol><p><b>Sorry, no results found.</b></p>";
# end script
Good luck... let me know how it works out for ya.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.