【问题标题】:Can't send email from google group account using Email::MIME in Perl / CC'd don't receive email无法使用 Perl 中的 Email::MIME 从 google 群组帐户发送电子邮件/抄送不接收电子邮件
【发布时间】:2020-11-17 02:35:59
【问题描述】:

每当在我的读取和解码 json 数据的 perl 脚本中发现不良内容时,我想从 google 群组帐户发送电子邮件通知。

这是我正在使用的:

  my $email = Email::MIME->create(
    header_str => [
      From           => 'test@googlegroup.com',
      To             => 'me@gmail.com',
      Cc             => ('other1@gmail.com', 'other2@gmail.com', 'other3@gmail.com'),
      Subject        => 'YOrg Refresh Failed: Bad File',
      'Content-Type' => 'text/html',
    ],
    body => "<p>All,</p><p>An error occurred while processing the data from the latest refresh.</p><p>Please look into this as soon as possible.</p>"
  );
  sendmail($email);
  die $response->status_line;

我首先使用我的个人电子邮件地址作为发件人(发件人)进行了测试,并且电子邮件按预期发送。但是当我使用组帐户地址('test@googlegroup.com')时,电子邮件没有发送出去。这也是一个有效的组帐户。所以我不确定为什么电子邮件不会从该帐户发送。

此外,在我从我的个人电子邮件地址发送的测试实例中,只有“other1@gmail.com”别名收到了电子邮件,其他抄送地址都没有收到。

【问题讨论】:

    标签: perl email mime


    【解决方案1】:

    问题的后半部分是您试图将列表分配给哈希值,而不是对匿名数组的引用。这个:

    Cc => ('other1@gmail.com', 'other2@gmail.com', 'other3@gmail.com'),
    

    应该是:

    Cc => ['other1@gmail.com', 'other2@gmail.com', 'other3@gmail.com'],
    

    既然你给它一个列表,Perl 会像这样解析你的语句:

    header_str => [
      From               => 'test@googlegroup.com',
      To                 => 'me@gmail.com',
      Cc                 => 'other1@gmail.com',
      'other2@gmail.com' => 'other3@gmail.com',
      Subject            => 'YOrg Refresh Failed: Bad File',
      'Content-Type'     => 'text/html',
    ],
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-05
      • 2013-05-28
      • 2015-05-03
      • 2019-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-24
      • 1970-01-01
      相关资源
      最近更新 更多