<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># This -*- perl -*- script makes the send_demo script
# $Id: send_demo.PL,v 1.2 1997/01/16 20:43:35 gbarr Exp $

$script = "./send_demo";

use Config;
use Cwd;
unlink($script);
$cwd = Cwd::getcwd();
open MIR, "&gt;$script" or die "open for writing $script: $!";
print MIR $Config{'startperl'}," -w\n";
#print MIR "use lib qw($cwd/blib);\n";
print MIR &lt;DATA&gt;; 
chmod(0755, $script);

__DATA__
require Mail::Internet;
require Mail::Alias;
use Getopt::Long;

sub expand_aliases 
{
 my $mail = shift;
 my $aliasfile = $ENV{HOME} . "/.mailrc";
 my($tag,$id);

 if( -f $aliasfile )
  {
   my $alias = Mail::Alias::Binmail-&gt;new($aliasfile);
   # Expand aliases

   foreach $tag (qw(To Cc Bcc)) 
    {
     @ids = ();
     foreach $id (Mail::Address-&gt;parse($mail-&gt;get($tag)))
      {
       my $addr = $id-&gt;address;
       my @expn = $alias-&gt;expand($addr);
       if(scalar(@expn) == 1)
        {
         $id-&gt;address($expn[0]);
         push(@ids,$id-&gt;format);
        }
       else
        {
         push(@ids,@expn);
        }
      }
     $mail-&gt;combine($tag,',');
     $mail-&gt;replace($tag, join(", ", @ids));
    }
  }
}


###
### Main program
###

GetOptions(qw(post nosig v));

$opt_post = 1 if $0 =~ m#(\A|/)post\Z#;

$verbose = defined $opt_v &amp;&amp; $opt_v ? 1 : 0;
$posting = defined $opt_post &amp;&amp; $opt_post ? 1 : 0;
$sign    = defined $opt_nosig &amp;&amp; $opt_nosig ? 0 : 1;

$mail =  Mail::Internet-&gt;new([ &lt;&gt; ]);

expand_aliases($mail);

$mail-&gt;add_signature if($sign);

if($posting)
 {
  my @groups = $mail-&gt;nntppost();

  if($verbose &amp;&amp; @groups)
   {
    $groups = "Newsgroups: " . join(", ", @groups);
    $groups =~ s/(.{10,78}),/$1\n/g if(length($groups) &gt; 78);
    print $groups,"\n";
   }
 }
else
 {
  $mail-&gt;delete('Newsgroups');
 }

@recp = $mail-&gt;smtpsend();

if($verbose &amp;&amp; @recp)
 {
  $recp = "Recipients: " . join(", ", @recp);
  $recp =~ s/(.{10,78}),/$1\n/g if(length($recp) &gt; 78);
  print $recp,"\n";
 }

exit;


</pre></body></html>