Date: Wed, 26 Mar 1997 06:13:27 GMT From: Tony Kimball <Anthony.Kimball@East.Sun.COM> To: current@freebsd.org Cc: ville@vlsi.fi Subject: Suggested fetchmail port addition (was: Re: Fetchmail nolonger working) Message-ID: <199703260613.GAA01499@compound.east.sun.com>
next in thread | raw e-mail | index | archive | help
Quoth Ville Eerola on Wed, 26 March:
: Normally fetchmail uses SMTP
: connection to the localhost to deliver the messages it downloads from
: the mail sever. Thus, you need to have a MTA listening to port 25 on
: the host runnig fetchmail, or alternatively you need to configure
: fetchmail to use a local MDA directly.
Speaking of which, here is a local MDA I use in order that I do not
have to run a local sendmail. Unless I am overlooking equivalent
functionality already hidden somewhere in the base OS, it might be
useful to include this in the fetchmail port.
/home/alk/.fetchmailrc:
server subtle proto imap user alk pass ******** mda /usr/local/bin/catmail
server saphire proto imap port 3131 user alk pass ******** mda /usr/local/bin/catmail
server perham proto pop3 user alk pass ******** mda /usr/local/bin/catmail
/usr/local/bin/catmail:
#!/usr/bin/perl
#
# name:
# catmail
# description:
# a mail delivery agent in perl
# usage:
# catmail [-{q,v}]* < mailstream
# environment:
# MAIL path to spool file
# synopsis:
# delivers a single mail message on stdin to the user spool file
# specified by the environment.
# author:
# alk@pobox.com
# date:
# 12 Mar 97
#
$verbose=0;
$quiet=1;
while ($ARGV[0]) {
if ($ARGV[0] =~ '^-.*[vV]') { $verbose=1; }
if ($ARGV[0] =~ '^-.*[qQ]') { $quiet=0; }
shift;
}
$mail=$ENV{'MAIL'};
if (! $mail) {
$mail=$ENV{'SPOOL'};
}
if (! $mail) {
$_=$ENV{'USER'};
if (!$_) {
$_=$ENV{'HOME'};
if ($_) {
s,.*/,,g;
}
}
if (-d '/var/mail') {
$mail="/var/mail/$_";
} elsif (-d '/usr/spool/mail') {
$mail="/usr/spool/mail/$_";
}
}
$_=$mail;
$user=s,.*/,,g;
die "Unable to set spool file path" unless $mail;
die "Unable to open spool file $mail" unless open(MAIL,">>$mail");
$line=0;
$replyto='';
$returnpath='';
$from='';
while (<STDIN>) {
if (/^Reply-To: ([-_.A-Za-z0-9]*@[-_.A-Za-z0-9]*).*/) {
$replyto=$1;
$header[$line++]=$_;
} elsif (/^Return-Path: .*<([-_.A-Za-z0-9]*@[-_.A-Za-z0-9]*)>.*/) {
$returnpath=$1;
$header[$line++]=$_;
} elsif (/^From: .*<([-_.A-Za-z0-9]*@[-_.A-Za-z0-9]*)>.*/) {
$from=$1;
$header[$line++]=$_;
} elsif (/^[A-Z][-A-Za-z]*: .*/) {
$header[$line++]=$_;
} elsif (/^\t/) {
$header[$line++]=$_;
} elsif (/^ /) {
$header[$line++]=$_;
} else {
$keep=$_;
last;
}
}
if ($from) {
$xfrom=$from;
} elsif ($replyto) {
$xfrom=$replyto;
} elsif ($returnpath) {
$xfrom=$returnpath;
} else {
$xfrom=$user
}
@WEEK=('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
@MONTH=('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($year > 38 && $year <= 99 ) {
$cent = 19;
} else {
$cent = 20;
}
printf MAIL "From %s %s %s %d %d:%02d:%02d %02d%02d\n",
$xfrom,$WEEK[$wday],$MONTH[$mon],$mday,$hour,$min,$sec,$cent,$year
|| die "Unable to append to $mail";
if ($verbose) { print ":"; }
for ($i=0; $line--; ) {
print MAIL $header[$i++] || die "Unable to append header line $i to $mail";
if ($verbose) { print ","; }
}
print MAIL "$keep";
while (<STDIN>) {
$i++;
print MAIL $_ || die "Unable to append mail line $i to $mail";
if ($verbose) { print "."; }
}
if ($verbose) { print "\n"; }
if (! $quiet) { print "$i lines output\n"; }
close(MAIL);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703260613.GAA01499>
