home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
2.x
/
plum2_32_1.lzh
/
module
/
log
/
mail.plm
< prev
next >
Wrap
Text File
|
1999-02-20
|
6KB
|
200 lines
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- $_ if 0; # -*- perl -*-
# $Id: mail.plm,v 2.11 1999/02/04 13:52:34 hasegawa Exp $
# copyright (c)1998-1999 Yoshinori Hasegawa <hasegawa@madoka.org>
package log_mail;
$DIRECTORY = '.';
$HOST = 'localhost';
$PROTO = getprotobyname('tcp');
$PORT = getservbyname('smtp', $PROTO) || 25;
$_ = 'log_mail';
sub main_loop {
local($userno) = @_;
local($file, $idx, $name, $code, $new, $adrs, $sno, $dir);
$sno = 0;
foreach $mail (&'property($userno, 'file')) {
($file, $adrs) = split(/\s+/, $mail);
next unless $adrs;
if (($idx = rindex($file, ';')) != -1) {
$name = substr($file, 0, $idx);
$code = substr($file, $idx + 1);
} else {
$name = $file;
$code = '';
}
$name = &'expand($name);
if ($name !~ /^[\\\/]/) {
$dir = &'expand(&'property($userno, 'directory') || $DIRECTORY);
$name = "$dir/$name";
}
$new = &'date($name);
if ($filename{$name} && $new ne $filename{$name}) {
if ($filename{$name} && -r $filename{$name}) {
$sno = &open($userno) unless $sno;
&send($userno, $sno, $filename{$name}, $code, $adrs) if $sno;
}
}
$filename{$name} = $new;
}
&close($sno);
}
sub open {
local($userno) = @_;
local($host, $port, $sno, $socket);
($host, $port) = split(/\:/, &'property($userno, 'smtpserver') || '');
$host = $HOST unless $host;
$port = $PORT unless $port;
if ($sno = &'connect($host, $port)) {
$socket = $'socket[$sno];
print $socket "NOOP\r\n";
while (defined($reply = <$socket>)) {
next if substr($reply, 0, 3) eq '220';
return $sno if substr($reply, 0, 3) eq '250';
last;
}
&'close($sno);
}
return 0;
}
sub close {
local($sno) = @_;
if ($sno) {
$socket = $'socket[$sno];
print $socket "QUIT\r\n";
&'close($sno);
}
}
sub send {
local($userno, $sno, $name, $code, $adrs) = @_;
local($from, $socket, $line, $reply, $date);
$socket = $'socket[$sno];
$from = &'property($userno, 'from') || '';
print $socket "RSET\r\n";
$reply = <$socket> || '';
return unless substr($reply, 0, 3) eq '250';
print $socket "MAIL FROM:<$from>\r\n";
$reply = <$socket> || '';
return unless substr($reply, 0, 3) eq '250';
foreach $item (split(/\,/, $adrs)) {
print $socket "RCPT TO:<$item>\r\n";
$reply = <$socket> || '';
if (substr($reply, 0, 3) eq '551') {
$reply =~ /\<([^\<\>]*)\>/;
$item = $1;
redo;
} elsif (substr($reply, 0, 3) ne '250' && substr($reply, 0, 3) ne '251') {
return;
}
}
print $socket "DATA\r\n";
$reply = <$socket> || '';
return unless substr($reply, 0, 3) eq '354';
print $socket "To: $adrs\r\n";
print $socket "Subject: $name\r\n";
print $socket "MIME-Version: 1.0\r\n";
print $socket "Content-Type: text/plain; charset=iso-2022-jp\r\n";
print $socket "Content-Transfer-Encoding: 7bit\r\n";
$date = &'date('%a, %d %b %Y %H:%M:%S JST');
print $socket "Date: $date\r\n";
print $socket "From: $from\r\n";
print $socket "\r\n";
if (open(FILE, $name)) {
while (defined($line = <FILE>)) {
$line =~ s/[\r\n]+//;
$line = '..=' if $line eq '.';
$line = &code_jis($line, $code);
print $socket $line, "\r\n";
}
close(FILE);
}
print $socket ".\r\n";
$reply = <$socket> || '';
}
sub code_jis {
local($line, $list) = @_;
foreach $code (split(/\,/, "\L$list\E")) {
if ($code eq 'euc') {
$line = &'euc_jis($line);
} elsif ($code eq 'jis') {
$line = &'jis_jis($line);
} elsif ($code eq 'sjis') {
$line = &'sjis_jis($line);
}
}
return $line;
}
__END__
--><HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-2022-JP">
<LINK REV="made" HREF="mailto:hasegawa@madoka.org">
<TITLE>log/mail.plm</TITLE></HEAD><BODY>
$B%*%s%i%$%s%I%-%e%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
</DL>
<HR><H3>$B@_DjNc(B</H3>
<PRE>
+ log/mail.plm
log.mail.from: plum@plum.or.jp
log.mail.smtpserver: mail.plum.or.jp:25
log.mail.file: log%m%d hogehoge@plum.gr.jp
log.mail.file: plum%m;euc hoehoe@plum.gr.jp,hogehoge@plum.or.jp
</PRE>
$B!V(Bplum@plum.or.jp$B!W$rAw?.85$H$7$F!"%m%0$r%a!<%k$GAw?.$7$^$9!#(B
$B$3$N$H$-!"(BSMTP$B%5!<%P$H$7$F!V(Bmail.plum.or.jp$B!W$N%]!<%H!V(B25$B!W$r;HMQ$7$^$9!#(B
$BAw?.$9$k%U%!%$%k$O(B2$B$D$G!"!V(Bhogehoge@plum.gr.jp$B!W08$K!V(Blog%m%d$B!W$r(B
$B!V(Bhoehoe@plum.gr.jp$B!W$H!V(Bhogehoge@plum.or.jp$B!W08$K!V(Bplum%m$B!W$rAw?.$7$^$9!#(B
log%m%d$B$H(Bplum%m$B$O$=$l$>$lF|IU$,E83+$5$l!"%U%!%$%k$NF|IU$,JQ$o$C$?$H$-$K(B
$B%a!<%k$GAw?.$7$^$9!#$=$N$?$a!"(Blog%m%d$B$O(B1$BF|(B1$B2s!"(Bplum%m$B$O(B1$B7n$K(B1$B2sAw?.$5$l$^$9!#(B
</BODY></HTML>