开发者

Sending email via Gmail

开发者 https://www.devze.com 2023-03-22 12:31 出处:网络
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):

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号