Reply-to 在 MIME Lite 中由于使用严格的 [=>(粗逗号)运算符]而出错

Reply-to in MIME Lite errors because of using strict [ => (fat comma) operator]

我使用 MIME::Lite 从我的 Perl 脚本发送电子邮件。我的 use strict; 在我的 header 中,因为这是我们所有脚本中的标准用法。

        my $msg = MIME::Lite->new(
            From => $from,
            To   => $to_str,
            Cc      => $cc_str,
            Reply-To    => $replyto,
            Subject => $tf_subject,
            Type    => 'multipart/mixed'
        );

当我在此函数中添加 Reply-To 以获取退回电子邮件时出现以下错误。

使用“严格订阅”时不允许使用裸词“回复”

但我在 MIME::Lite 的文档中看到 Reply-To 是获得退回电子邮件的唯一方法。

有没有办法在同一个脚本中同时容纳严格和 Reply-To?

        Reply-To    => $replyto,

它应该是 'Reply-To'(引用)而不是 Reply-To - 除非你想从 Reply.

中减去 To

Reply-To 放在引号中。做到 'Reply-To'

my $msg = MIME::Lite->new(
  From => $from,
  To   => $to_str,
  Cc      => $cc_str,
  'Reply-To'    => $replyto,
  Subject => $tf_subject,
  Type    => 'multipart/mixed'
);

解释:

man perlop

The "=>" operator (sometimes pronounced "fat comma") is a synonym for the comma except that it causes a word on its left to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores. This includes operands that might otherwise be interpreted as operators, constants, single number v-strings or function calls. If in doubt about this behavior, the left operand can be quoted explicitly.

Otherwise, the "=>" operator behaves exactly as the comma operator or list argument separator, according to context.