use Mail::Bulkmail;
my ($subject, $message);
open(MSG, "message.txt");
while (<MSG>) {
if ($_ =~ /^[Ss]ubject:\s*(\S*)/) {
$subject = $1;
} else {
$message .= $_;
}
}
close MSG;
my $bulk = new Mail::Bulkmail(
Message => $message,
Subject => $subject,
From => 'Home',
LIST => 'email.txt'
use_envelope => 1,
);
$bulk->bulkmail();
If you have an older version of Mail::Bulkmail than you can simplify this even more by using the HFM (Headers From Message) feature that has dissapeared from version 3.x.
use Mail::Bulkmail;
open(MSG, "message.txt");
undef $/;
my $message = <MSG>;
close MSG;
my $bulk = new Mail::Bulkmail(
Message => $message,
From => 'Home',
LIST => 'email.txt'
use_envelope => 1,
HFM => 1, # pull headers from message
);
|