use strict;
use Net::SMTP;
sub SendNews {
my($firstname, $emailaddress) = @_;
my $message = "Dear ".$firstname.",\n\nThis is our newsletter!\n\n";
my $ServerName = "smtp.1and1.com:587";
my $ServerAccount = "sample\@samples.com";
my $ServerPwd = "dsdjkj2332";
my $MailFrom = "sample\@samples.com";
my $MailTo = $emailaddress;
use Mail::SendEasy ;
my $status = Mail::SendEasy::send(
smtp => 'smtp.mail.com:587' ,
user => $ServerAccount ,
pass => $ServerPwd ,
from => $MailFrom ,
from_title => 'Your Name' ,
to => $MailTo ,
subject => "Your Subject" ,
msg => $message
) ;
if (!$status) { Mail::SendEasy::error ;}
print "Finished sending email to ".$firstname." through ".$MailTo."\n";
}
# contacts.txt has the following structure
#First Name;Last Name;E-mail address
open (CFILE, "contacts.txt") or die("Could not open contacts file.");
foreach my $line (<CFILE>) {
chomp($line);
my($fname, $lname, $emailadd) = split(/;/,$line);
$fname = ucfirst($fname);
#$emailadd =~ s/\@/\\\@/;
#print $fname." - ".$emailadd."\n";
SendNews($fname, $emailadd);
sleep 1;
}
We have 8 guests and no members online