![邮箱的 Postfix 正则表达式映射](https://linux22.com/image/629069/%E9%82%AE%E7%AE%B1%E7%9A%84%20Postfix%20%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%98%A0%E5%B0%84.png)
我需要通过某个掩码将邮箱收到的所有电子邮件转发到一个特定邮箱。例如,如果收件人邮件是 79001234567,则应该转发。
来自 /etc/postfix/main.cf 的行
virtual_alias_maps = $alias_maps, $virtual_maps, ldap:/etc/postfix/imap-aliases.cf, ldap:/etc/postfix/imap-groups.cf, regexp:/etc/postfix/dummyregexp
这是我使用的正则表达式:/etc/postfix/dummymail
/^7\d{10}@domain.tld/ [email protected]
/var/log/maillog 的一部分
Mar 17 01:39:23 mail postfix/smtpd[24228]: connect from mail-qa0-f52.google.com[209.85.216.52]
Mar 17 01:39:23 mail postfix/smtpd[24228]: setting up TLS connection from mail-qa0-f52.google.com[209.85.216.52]
Mar 17 01:39:24 mail postfix/smtpd[24228]: Anonymous TLS connection established from mail-qa0-f52.google.com[209.85.216.52]: TL
Sv1 with cipher RC4-SHA (128/128 bits)
Mar 17 01:39:24 mail postfix/smtpd[24228]: NOQUEUE: reject: RCPT from mail-qa0-f52.google.com[209.85.216.52]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail-qa0-f52.google.com>
Mar 17 01:39:25 mail postfix/smtpd[24228]: disconnect from mail-qa0-f52.google.com[209.85.216.52]
Mar 17 01:39:57 mail imaps[23602]: accepted connection
另外,我尝试在 /etc/postfix/dummymail 中添加其他行,这一行对我有用
/[email protected]/ [email protected]
所以我认为我的正则表达式有问题。
答案1
\d
用 POSIX 字符类替换:
/^7[[:digit:]]{10}@domain.tld/ [email protected]