【问题标题】:Sending email via Gmail通过 Gmail 发送电子邮件
【发布时间】:2023-03-19 12:54:01
【问题描述】:

我的电子邮件发送代码在没有任何错误消息的情况下无法正常工作(“不起作用”是指所有接缝都正常,但我我的邮箱中没有消息):

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";
}

你能告诉我它有什么问题吗?

【问题讨论】:

  • “find”的不相关但过去式是“found”而不是“find”。
  • 谢谢。我会努力学习我的英语。

标签: perl email gmail ssl


【解决方案1】:

Email::Send::Gmail 可能会让您的生活更轻松。

【讨论】:

  • 感谢您指点我这个模块!现在我在我的代码中使用它,但问题仍然在我脑海中:为什么这段代码不起作用?
猜你喜欢
  • 2012-01-07
  • 2016-09-26
  • 2011-06-01
  • 2018-03-21
  • 2016-09-09
  • 2019-01-24
相关资源
最近更新 更多