Hello, Some users here wanted to "Reply to" archived mail messages. Below is my solution. This puts a "Reply to this message" button on every message. Note that the script attempts to preserve threading by reading the "In-reply-to" and "references" headers.
The script can probably be improved, but works well for us. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Phil Macias * [EMAIL PROTECTED] * Princeton, NJ ___,_ |_|_, 609 987 5059 office | 609 203 5874 cell `/`-- ------------------------------------ STEPS: 1. put this is mhonarc.rc: ## "reply-to" link <HEADBODYSEP> <center> <form><input type="button" value="Respond to this message" onClick="window.open('/cgi-bin/mailer.pl?file=$MSG$&path=$OUTDIR$&from=$FROMADDR$', 'Example1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=500,height=300')"></form></center> <hr> </HEADBODYSEP> 2. place the file "mailer.pl" in your cgi-bin directory 3. archives are created with this command: /usr/bin/mhonarc -expireage 15768000 -add -force $archive_dir/$_ -title $_ -outdir $doc_dir/$_ -rcfile /httpd/KSC/mhonarc.rc mailer.pl: ---------------------------------------- #!/usr/bin/perl ## you want to change this $majordomo_server = "majordomo.gfdl.noaa.gov"; ################################################### print "Content-type: text/html\n\n"; if ( ($type eq "") || ($ENV{'QUERY_STRING'}) ) { ## this allows for the "links as form buttons" if ($ENV{'QUERY_STRING'}) { foreach(split(/&/, $ENV{'QUERY_STRING'}) ) { ($name, $value) = split(/=/); $hash{$name} = $value; ## print "$name=$value<br>"; } } else { read( STDIN,$message,$ENV{CONTENT_LENGTH} ); $* = 1; # multi-line matching @items = split( /&/, $message ); foreach $item ( @items ) { local( $name,$value ) = split( /=/, $item ); $name =~ s/%([\da-f][\da-f])/pack("C",hex($1))/gei; $name =~ s/\+/ /g; $name =~ s/([\w\W\s+\n])\+/$1 /; $value =~ s/%2B/PLUS_SIGN/gi; $value =~ s/%([\da-f][\da-f])/pack("C",hex($1))/gei; $value =~ s/\+/ /g; $value =~ s/([\w\W\s+\n])\+/$1 /; $value =~ s/PLUS_SIGN/\+/g; $hash{$name} = $value; ## to check variables ## print "$name=$value<br>"; } } } if (!$hash{'action'}) { $cat = `lynx -dump $hash{'path'}/$hash{'file'}`; ## get the subject, ignoring all "Re:" ($subject) = $cat =~ /\s+\* Subject:(.*)\n/; $subject =~ s/^(\s?Re:){1,}//i; $subject = "Re:$subject"; $divider = " _________________________________________________________________\n"; ($text) = $cat =~ /\n\s+\[BUTTON\]\n$divider(.*)$divider/s; $text =~ s/\n/\n > /g; ($also_to) = $hash{'path'} =~ /.*\/(.*)\.archive$/; $also_to = $also_to . "\@$majordomo_server"; print "<FORM METHOD=\"POST\" ACTION=\"/cgi-bin/mailer.pl\">"; print "<font size=-1><input type=hidden name=action value=mail>"; print "To: <input size=60 name=\"to\" value=\"$also_to\"><br>"; print "Cc: <input size=60 name=\"cc\" value=\"$hash{'from'}\"><br>"; print "Bcc: <input size=60 name=\"bcc\"><br>"; print "From: <input size=60 name=\"from\"><br>"; print "Subject: <input size=60 name=\"subject\" value=\"$subject\"><br>"; ## "reply-to:" headers ## ## first look for "in-reply-to" then "references" ($message_id) = `grep X-Message-Id $hash{'path'}/$hash{'file'}` =~ /X-Message-Id: (.*) --\>/; ## if it has a ";" it ain't a good reference if ($message_id =~ /\;/) { ($message_id) = `grep X-Reference $hash{'path'}/$hash{'file'}` =~ /X-Reference: (.*) --\>/; } print "<p>In-reply-to: <$message_id><br>"; print "<input type=\"hidden\" name=\"in-reply-to\" value=\"$message_id\">"; print "References: <$message_id><p>"; print "<textarea name=\"text\" rows=40 cols=80>$text</textarea>"; print "<center><INPUT VALUE=\"Submit\" TYPE=\"submit\"></form></center>"; } if ($hash{'action'} eq "mail") { open (EMAILIT, "|/usr/lib/sendmail -t"); print EMAILIT "To: $hash{'to'}\n"; print EMAILIT "Cc: $hash{'cc'}\n"; print EMAILIT "Bcc: $hash{'bcc'}\n"; print EMAILIT "From: $hash{'from'}\n"; print EMAILIT "Subject: $hash{'subject'}\n"; print EMAILIT "In-reply-to: <$hash{'in-reply-to'}>\n"; print EMAILIT "References: <$hash{'in-reply-to'}>\n"; print EMAILIT "--text follows this line--\n\n"; print EMAILIT "$hash{'text'}\n"; close (EMAILIT) || die "Message could not be delivered\n."; print "<p><b>Message sent</b>"; } __ END __