L
Lars Roland
Hi all
I use the folowing script to send email directly to a server (using its ip
address), my problem is that the script nerver halts (eg. its while loop
semas to run forever), can someone in here see why this is so ? as I can
not understand this:
--------------------------------------------
#!/usr/bin/perl
use strict;
use MIME::Entity;
my $mailhost = shift(@ARGV);
my $recip = shift(@ARGV);
my $sender = shift(@ARGV);
my $subject = shift(@ARGV);
my $nrofmsg = shift(@ARGV);
if ($mailhost =~ /--help/)
{
die "usage: mail.pl smtp-server recipient sender subject nrofmails.
The e-mail body is empty"
};
my $nrofsend = 1;
#the e-mail
my $message;
$message="Test";
while( $nrofsend <= $nrofmsg)
{
fork;
# MIME stuff
my $top = MIME::Entity->build(Type =>"multipart/mixed",
From => "$sender",
To => "$recip",
Subject => "Messages number $nrofsend:
$subject");
print STDOUT "Sending message $nrofsend of $nrofmsg\n";
# contact $mailhost
$top->smtpsend( Host => $mailhost,
To => $recip,
From => $sender,
Hello=> "HELO",
Port => 25) || die;
++$nrofsend;
sleep 1;
};
--------------------------------------------
example of use (if the code is put in mail.pl)
../mail.pl IP-OF-MAILSERVER RECIPIENT@EMAIL SENDER@EMAIL SUBJECT NUM_OF_EMAILS
Thanks in advance
I use the folowing script to send email directly to a server (using its ip
address), my problem is that the script nerver halts (eg. its while loop
semas to run forever), can someone in here see why this is so ? as I can
not understand this:
--------------------------------------------
#!/usr/bin/perl
use strict;
use MIME::Entity;
my $mailhost = shift(@ARGV);
my $recip = shift(@ARGV);
my $sender = shift(@ARGV);
my $subject = shift(@ARGV);
my $nrofmsg = shift(@ARGV);
if ($mailhost =~ /--help/)
{
die "usage: mail.pl smtp-server recipient sender subject nrofmails.
The e-mail body is empty"
};
my $nrofsend = 1;
#the e-mail
my $message;
$message="Test";
while( $nrofsend <= $nrofmsg)
{
fork;
# MIME stuff
my $top = MIME::Entity->build(Type =>"multipart/mixed",
From => "$sender",
To => "$recip",
Subject => "Messages number $nrofsend:
$subject");
print STDOUT "Sending message $nrofsend of $nrofmsg\n";
# contact $mailhost
$top->smtpsend( Host => $mailhost,
To => $recip,
From => $sender,
Hello=> "HELO",
Port => 25) || die;
++$nrofsend;
sleep 1;
};
--------------------------------------------
example of use (if the code is put in mail.pl)
../mail.pl IP-OF-MAILSERVER RECIPIENT@EMAIL SENDER@EMAIL SUBJECT NUM_OF_EMAILS
Thanks in advance