use lib $ENV{"PERLMAIL_BASEDIR"} || File::Basename::dirname($0);
# FIXME:
- use lib "/home/lace/lib/perl5/site_perl/5.10.0";
- use lib "/home/lace/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi";
+ use lib $ENV{"HOME"}."/lib64/perl5";
+ use lib $ENV{"HOME"}."/lib/perl5";
+ use lib $ENV{"HOME"}."/share/perl5";
use PerlMail::Config;
use PerlMail::Lib;
while (1) {
local $/="\n";
+ $!=undef();
my $length=<STDIN>;
- confess "Unexpected EOF" if !defined $length;
+ confess "Unexpected EOF: $!" if !defined $length;
confess "Missing EOL" if $length!~s/\n$//s;
exit 0 if $length eq "BYE";
confess "Unrecognized length: $length" if $length!~/^\d+$/;
return @AuditStored!=$did_last;
}
+sub writeto
+{
+my($filename)=@_;
+
+ local *F;
+ open F,$filename or confess "open $filename: $!";
+ print F $Message or confess "write $filename: $!";
+ close F or confess "close $filename: $!";
+ return 1;
+}
+
# Never use Mail::Audit->store() as it will reformat MIME bodies and possibly corrupt OpenPGP!
sub write_message
{
# prevent Razor2's: Can't call method "log" on unblessed reference at Razor2/Client/Agent.pm line 212.
local $ENV{"HOME"}=$HOME;
# 2>/dev/null to prevent error messages to corrupt inetd() output of perlmail-accept(1)
- open CHILD,"|$cmd >/dev/null 2>/dev/null"
+ open CHILD,"|$cmd &>/dev/null"
+ # Workaround: spamassassin-3.1.3-1.fc5
+ #.q{|awk '/^X-Spam-Flag: YES$/{if (!body) exit 1;}/^$/{body=1;}'}
+ # Original:
+ #." >/dev/null 2>/dev/null"
or return 0;
print CHILD $Message;
close CHILD;
$Audit->replace_header($header,$text);
}
-# LMTP engine:
-use Net::Cmd qw(CMD_OK CMD_MORE);
-{
- package My::Net::SMTP::LMTP;
- require Net::SMTP;
- our @ISA=qw(Net::SMTP);
- use Net::SMTP;
- use Net::Cmd qw(CMD_OK);
- use Carp qw(confess cluck);
-
- # Do not: sub _HELO
- # as it would not set {'net_smtp_esmtp'}
- sub _EHLO { shift->command("LHLO", @_)->response() == CMD_OK }
-
- sub clucked
- {
- my($self,$func,@args)=@_;
-
- do { return $_ if defined $_; } for $self->$func(@args);
- cluck $func;
- return;
- }
-}
-
-
-sub lmtp_deliver
-{
-my($admin_user,$admin_pwd,$user_from,$user_to)=@_;
-
- my $lmtp=My::Net::SMTP::LMTP->clucked("new","localhost","Port"=>"lmtp",
-# "Debug"=>1,
- ) or return;
- bless $lmtp,"My::Net::SMTP::LMTP";
-# Prevent:
-# due to:
-# $lmtp->auth(Authen::SASL->new(
-# "mechanism"=>"PLAIN",
-# "callback"=>{
-# "user"=>$admin_user,
-# "pass"=>$admin_pwd,
-# # Prevent: "authname"=>$admin_user
-# # as it causes: DIE: Unknown callback: 'authname'. (user|auth|language|pass)
-# }));
- # FIXME: Authentication hack:
- $lmtp->command("AUTH PLAIN")->response()==CMD_MORE
- or do { cluck "auth announce"; return; };
- $lmtp->clucked("command",encode_base64($user_from."\x00".$admin_user."\x00".$admin_pwd)) or return;
- $lmtp->clucked("mail",$user_from) or return;
- $lmtp->clucked("to",$user_to) or return;
- $lmtp->clucked("data"); # Do not: or return;
- # Prevent: 554 5.6.0 Message contains invalid header
- (my $data=$Message)=~s/\AFrom .*\r?\n//;
- $lmtp->clucked("datasend",$data) or return;
- $lmtp->clucked("dataend") or return;
- $lmtp->clucked("quit") or return;
-}
-
-
# MAIN
$Getopt::Long::ignorecase=0;