Chomp not working properly with Sendmail

A

Aaron Powell

I am writing a program for a study I am doing where I must contact several
different organisations stored in a database I compiled, but I need to send
each email one at a time so they don't know who else I sent to.

I tested my sendmail and it works well, but I am having a problem with chomp
in the case I am using it. When getting $email, if I do not say $email\n,
nothing will be displayed to the command prompt. This leads me to believe
that sendmail is also receiving nothing in the To field as its displaying no
recipient has been specified, though it also displays that if you put data
in that it doesn't understand, such as $email with a \n.

Finally, it will always send the last record, the last record in the file
works fine, the rest are the ones that are not understandable.

Any help is appreciated, thank you.

The code is show bellow.

#!/usr/bin/perl

use SendMail;

my $message = "message"

open (FILENO, "emails.txt");
my @file = <FILENO>;
close (FILENO);

foreach $email (@file){

$sm = new SendMail("mailserver");
$sm->setDebug($sm->ON);
$sm->From("me\@me.com");
$sm->Subject("Header");
chomp $email;
print "$email\n";
$sm->To("$email");
$sm->setMailBody("$message");
#
# Check if the mail sent successfully or not.
#
if ($sm->sendMail() != 0) {
print $sm->{'error'}."\n";
}
print "Done\n";
}
exit 0;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top