简体   繁体   中英

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},
                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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM