Sending email via Gmail
I have email sending code which doesn't work without any error messages (by "doesn't work" i mean all seams OK but i have no message in my mail box):
use strict;
use warnings;
use Email::Send;
use Email::Simple::Creator;
report_update();
sub report_update {
my $mailer = Email::Send->new(
{
mailer => 'SMTP::TLS',
mailer_args => [
Host => 'smtp.gmail.com',
Port => 587,
User => $CONFIG{EMAIL_USER},
开发者_Go百科 Password => $CONFIG{EMAIL_PASS},
Hello => 'localhost',
]
}
);
my $email = Email::Simple->create(
header => [
From => $CONFIG{EMAIL_USER},
To => $CONFIG{TARGET_EMAIL},
Subject => 'Updated info finded!',
],
body => 'Updated info finded!',
);
eval { $mailer->send($email) };
die "Error sending email: $@" if $@;
print "Finished!\n";
}
Could you give me a hint what's wrong with it?
There is an Email::Send::Gmail which might make your life easier.
精彩评论