From the script below, the commented part of the script is to prevent the script from hanging. The script as is , is working once I uncomment the openning of the file to retieve the body of the email, the script hang.
use Email::Send;
use Email::Send::Gmail;
use Email::Simple::Creator;
# open the file that contains the body of the email
# local $/ = undef;
# open(FH,'<','body.txt') or die "file does not exists $!";
# my $body=<FH>;
# close(FH);
my $email = Email::Simple->create(
header => [
From => 'arishy@gmail.com',
To => 'arishy@gmail.com',
Subject => 'testing sent mail to gmail',
],
body => 'this is the body that works',
## if I uncomment the openning of a file to get the body of the email
## like this body => $body,
);
my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => 'arishy@gmail.com',
password => 'xxxxxxxxx',
]
}
);
eval { $sender->send($email) };
die "Error sending email: $@" if $@;
arishy 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.