[lug] mail responders
bdoctor at ps-ax.com
bdoctor at ps-ax.com
Wed Apr 11 07:15:34 MDT 2001
I've included a script I use at the bottom -- not perfect or pretty but it works
well.
-brad
>
> anyone have a recommendation for a mail responder that *doesnt* rely on
> procmail or a .forward file?
>
> i am really looking just to
>
> respond: "| /usr/local/bin/mailrespond.pl"
>
> but my perl is pretty weak.
>
>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
>
--------------
#!/usr/local/bin/perl
# $Source: /cvs/users/inform.pl,v $
# $Revision: 1.3 $
# $Date: 1999/02/11 20:40:59 $
#
# This software was designed and written by Brad Doctor (bdoctor at ps-ax.com)
# Redistribution and use are permitted under the terms of the GNU Public
# License.
use strict;
my $sendmail_BIN = "/usr/sbin/sendmail"; # where is sendmail?
my $postmaster = "postmaster\@yourhost.com"; # define local postmaster
my $subject = "User unknown"; # whatever the subject should be
my $newdomain = ""; # user's new domain?
use vars qw($from_holder $to_holder $subject_holder $null $From $To);
use vars qw($person $message);
while (<STDIN>) {
chomp;
if ( /From\ / ) {
$from_holder = $_;
} elsif ( /To\:\ / ) {
$to_holder = $_;
} elsif ( /Subject\:\ / ) {
$subject_holder = $_;
}
}
&inform_sender;
sub inform_sender {
$from_holder =~ (s/\ /\:/g);
($null,$From) = split(/\:/, $from_holder);
($null,$To) = split(/\:/, $to_holder);
$To =~ (s/\ //g);
($person,$null) = split(/\@/, $To);
$subject_holder =~ (s/Subject\:\ //g);
#print "From:$From\nTo:$To\nSubj:$subject_holder\n";
# change message to whatever is appropriate
$message = "
The address you are using is invalid.
postmaster\@yourhost.com
";
open (DELIVER, "| $sendmail_BIN -oi $From") ||
die "Can't create output: $!\n";
print DELIVER "
To: $To
From: $postmaster
Subject: $subject_holder
Notice: Invalid address
---------------------------------------
";
print DELIVER $message;
close DELIVER;
}
More information about the LUG
mailing list