[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ZMailer message submission in PERL..

I asked for a PERL-version of the posting, and this I got back.
In commentary letter Janne Edelman said (in finnish) about:

"This reads in from stdin, and sends to all addresses given as
 parameters.  Even though this sends all messages individually,
 it would be trivial to use more envelope 'to '-lines.  Should
 add sometimes.

 The input text must have RFC822 headers in it.

 ... and of course I could have answered directly to the person
 originating the question, but I am a bit tired at this late at

I THINK this needs Perl5, though I am not sure.

/Matti Aarnio

#  LightPost for ZMailer
#  Version 0.1
#  Copyright (c) 1996 Janne Edelman
#  You may copy and use this piece of software under GPL
#  Usage: lightpost [-t] email@address [ email@address ... ] < file
#  File must contain full headers with From, To, Subject, etc.
#  This script does NOT check the file at any way.
#  This script only adds the envelope at the begining of outgoing email
#  and allows mass postings with the same content.
#  With -t option the To header is changed to same as given email address

if( ! -r '/etc/zmailer.conf') {
  die "Can't open zmailer.conf\n";

while(<ZMAILER>) {
close ZMAILER;

require 'getopts.pl';


while(<STDIN>) {
  if($_ eq "\n") { $part='body' }

foreach $hl ('Message-Id:','X-Mailer:','Cc:','Bcc:') {

if($opt_t) {

$outfile = $ZMAILER{'POSTOFFICE'} . "/public/lightpost.$$";
$hostname=`hostname`; chomp $hostname;
$domainname=`domainname`; chomp $domainname;
foreach $address (@ARGV) {
  print "to $address\n";
  print "env-end\n"; # added by [mea]
  if($opt_t) {
    print "To: $address\n";
  print @header;
  print "Message-Id: <${time}.${count}.LP\@${hostname}.${domainname}>\n";
  print "X-Mailer: LightPost for Zmailer\n";
  print @body;
  close OUT;
  $newfile=$ZMAILER{'POSTOFFICE'} . "/router/$inode";
  rename($outfile, $newfile);
print "$count messages send\n";

sub strip_header {
  return grep(!/^$_[0]/i, @_[1..$#_]);

	Janne K Edelman - PGP public key: finger edelman/pgp@tuug.utu.fi