#!/usr/bin/perl # # MAILLINK.CGI # by Matt Kruse # 7/8/95 # # This is a simple script, but I find it very useful. # It reads your mail, looks for WWW sites, and exports them to a hotlist # for you to use later quite easily. It also puts a mailto: link to the # author of each message. # It was written using perl 4.036 on a linux system. # Using it on different systems will probably require some modifications. # # USAGE # To use this script, you need to change your .forward file in your home # directory. It should look like this: # # \username <------Your username here # "| maillink.cgi" <------Point this to your script. # # Your mail will now be filtered automatically and your hot list updated # every time a new message comes in. If you don't know how any of this # works, it might be a better idea to learn about it first. require "ctime.pl"; # Where your hotlist is stored. $HTML="html/mail.html"; # figure out when this thing came in $date= &ctime(time); @date=split(' ',$date); $date= "$date[0] $date[1] $date[2]"; undef $/; $*=1; # READ IN THE MESSAGE $_=; # READ IN THE CURRENT LINKS FILE open(INPUT,"$HTML"); $TEXT=; close(INPUT); open (OUTPUT,">> $HTML"); if ($TEXT !~ $date) { print OUTPUT "\n"; print OUTPUT "

$date

\n"; } ($SUBJECT) = /Subject: ([^\n]*)\n/; $SUBJECT=~s//>/g; ($FROM) = /(\w+@[\w\.]+)/; $ADD=0; foreach $link ( /(http:[^">\s]+)/ig ) {if ($TEXT !~ $link) { $ADD=1; } } if ($ADD == 1) { print OUTPUT "
From:\n"; print OUTPUT "$FROM
\n"; print OUTPUT "Subject: $SUBJECT\n"; foreach $link ( /(http:[^">\s]+)/ig ) { if ($TEXT !~ $link) { print OUTPUT "
$link\n"; $TEXT=$TEXT . $link; } } print OUTPUT "
\n"; } close(OUTPUT);