procmail
[Top] [All Lists]

Re: auto-replying -- sending back the _headers_

1997-03-26 21:09:53
On Wed, 26 Mar 1997, Timothy J. Luoma wrote:


I am helping a few people debug their sendmail configs.  They are  
trying to make sure all their headers are in the right order, etc.

I would like to be able to setup a thing where they could send me a  
message with a certain subject and get an automated response -- but  
the response would/should include all the headers from their  
original message (so they can check out their 'From ' lines, etc.)

[ Note: they are using 'Reply-To' lines so there will be a valid  
address available for the autoresponder....]

How about piping the message to a perl script?  

#!/bin/perl

$data = "";
while ($line = <STDIN>) {
    $data = "$data$line";
    chop($line);
    if ($line =~ /^$/) { last ; }
    if ($line =~ /^Subject: (.*)$/ ) { $SUBJECT = $1 ; }
    if ($line =~ /^From: (.*)$/) {                          # Get from
        $from = $1 ;
        if ($from =~ /<(.*)>/) { $from = $1 ; }
        else { $from =~ s/(\S+)\s(.*)$/$1/ ; }
        $from =~ /(.*)\@(.*)/;
   }
}

$line1 = "From: TjL AutoReplier <luomat(_at_)peak(_dot_)org>\n";
$line2 = "To: $from";
$line3 = "Subject: Re: $SUBJECT";
$line4 = "X-Loop: luomat(_at_)peak(_dot_)org\n\n"
$line5 = "$data";
$line6 = ".\nquit\n";

$total = "$line1$line2$line3$line4$line5$line6";

###
# Finally ship it off to the port and data handling program to be sent
open(SENDTOPORT, "| /usr/lib/sendmail -t ");
print SENDTOPORT "$total";
close SENDTOPORT;

-- 
Bubble Memory, n.:
        A derogatory term, usually referring to a person's
        intelligence.  See also "vacuum tube".