【问题标题】:Spamassassin regex header rule not workingSpamassassin 正则表达式标头规则不起作用
【发布时间】:2018-02-12 11:56:41
【问题描述】:

我是 Spamassassin、正则表达式和 Perl 的新手,所以我很感激一些帮助。我试图为发件人遵循特定模式的所有电子邮件添加垃圾邮件分数,即: name.surname.@example.com。 这就是我想出来的

header NAME_DOT_SURNAME_DOT_FQDN From=~((?:[a-z]+))(\\.)((?:[a-z]+))(\\.)(@)((?:[a-z][a-z\\.\\d\\-]+)\\.(?:[a-z][a-z\\-]+))(?![\\w\\.])
score NAME_DOT_SURNAME_DOT_FQDN 3.0

但是,它似乎不起作用。当我运行spamassassin --lint 时,我得到以下输出:

Feb 12 12:52:59.521 [32767] warn: Use of ?PATTERN? without explicit operator is deprecated at /etc/spamassassin/local.cf, rule NAME_DOT_SURNAME_DOT_FQDN, line 1.
Feb 12 12:52:59.522 [32767] warn: rules: failed to compile Mail::SpamAssassin::Plugin::Check::_head_tests_0_3, skipping:
Feb 12 12:52:59.522 [32767] warn:  (Unmatched ) in regex; marked by <-- HERE in m/: [...][a-z]+) <-- HERE )(\\.)((/ at /etc/spamassassin/local.cf, rule NAME_DOT_SURNAME_DOT_FQDN, line 1.)
Feb 12 12:52:59.620 [32767] warn: lint: 1 issues detected, please rerun with debug enabled for more information

运行spamassassin --lint -D 只会产生包含相同错误的文本墙。 谁能指出我正确的方向?提前致谢。

【问题讨论】:

    标签: regex perl spamassassin


    【解决方案1】:

    我不知道 SpamAssassin,但它是否需要 / / 围绕正则表达式?

    因为错误消息表明 Perl 将 ? 视为正则表达式分隔符,导致正则表达式为:

    ?:[a-z]+))(\\.)((?
    #-------^ unmatched ')'
    

    所以我想尝试的是:

    header NAME_DOT_SURNAME_DOT_FQDN From=~/((?:[a-z]+))(\\.)((?:[a-z]+))(\\.)(@)((?:[a-z][a-z\\.\\d\\-]+)\\.(?:[a-z][a-z\\-]+))(?![\\w\\.])/
    

    此外,那些双反斜杠看起来很可疑。你确定你不是说例如\w 而不是 \\w

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多