[LUGOS] Postfix send-only
Matija Grabnar
matija.grabnar at arnes.si
Wed Nov 12 13:41:43 CET 2003
Naredis majhen program v perlu, ki uporablja Net::SMTP in zadeva je
resena.
Nekaj takega: (skriptica ima morda kaksno napako, ker sem sproti brisal ven
zadeve, ki so specificne za mojo rabo).
#!/usr/bin/perl -w
#use strict;
use Net::SMTP;
while ($#ARGV>=0) {
if ($ARGV[0] eq "-s") {
$subj=$ARGV[1];
shift @ARGV;
shift @ARGV;
} else {
push(@to,$ARGV[0]);
shift @ARGV;
}
}
$subj="(no subject)" unless defined($subj);
$connect="moj.smtp.host" unless defined($connect);
$smtp = Net::SMTP->new($connect) || Net::SMTP->new('moj.rezervni.host');
$smtp->mail("kiosk at moja.domena");
#$smtp->to($toaddr);
foreach (@to) {
$smtp->to("$_");
}
$smtp->data();
unless ($forward) {
$smtp->datasend("To: $toaddr\n");
$smtp->datasend("From: matija.grabnar\@arnes.si\n");
$smtp->datasend("Subject: $subj\n");
$smtp->datasend("Date: $date\n");
$smtp->datasend("\n");
} else {
while (($_=<>)!~/^\s*$/) {
if (/^From:\s*(.*)$/ and $1!~/\@/) {
my $part=$1;
$part=~/(\S+)/;
$smtp->datasend("From: $1\@nanos.arnes.si\n");
} else {
$smtp->datasend($_);
}
if (/^Date:/) {$seendate=1;}
if (/^To:/) {$seento=1;}
}
$smtp->datasend("To: $toaddr\n") unless ($seento);
$smtp->datasend("Date: $date\n") unless ($seendate);
$smtp->datasend("\n");
}
while (defined($_=<STDIN>)) {
$smtp->datasend($_);
}
$smtp->dataend();
$smtp->quit;
More information about the lugos-list
mailing list