Hi Monks,
I'm using Mail::Mailer to send an email to a bunch of email address i read from a text file...problem is, the 'from' field doesn't come up correctly - the actual from field is saying my email address from the system which is running the perl script, but then in the body of the message it has up the top:
From: correct_email@address.com
how can i get it so that the actual from field has this address? following is my code:
#!/usr/bin/perl -w
#this program emails to a list of people stored in the file address.tx
+t
#address.txt is of the form: first name <space> second name <tab> emai
+l
use strict;
use Mail::Mailer;
sub splitStuff{ #split the text file into appropriate fields
open(INFILE, "2address.txt");
my $from_address = "correct_email\@address.com";
my $subject = "test email - ignore";
my $to_address;
my ($name, $firstnm, $lastnm);
while (<INFILE>) {
my $line = $_;
($name, $to_address)=split("\t");
($firstnm, $lastnm)=split(" ", $name);
if ($to_address !~ /\@/)
{
print "There is no email address for $
+name. No e
mail sent. \n";
next;
}
&mail($to_address, $from_address, $subject, $firstnm,
$lastnm);
print "Email sent to $firstnm $lastnm, email: $to_addr
+ess \n";
}
}
sub mail () {
my ($to_address, $from_address, $subject, $firstnm, $lastnm) =
+ @_;
#body
my $body="hello $firstnm, \n how are you";
my $mailer = Mail::Mailer->new("sendmail");
$mailer->open({
From => $from_address,
To => $to_address,
Subject => $subject,
}) or die ("error $firstnm, $lastnm");
print $mailer $body;
$mailer->close();
}
&splitStuff;
close(INFILE);
any help would be much appreciated!
Thanks,
dsm