在postfix队列中改变接收

运行postqueue -p我有时会发现拼写错误的电子邮件地址,
有没有办法改变信息的接收地址(信封地址)
所以它可以交付。

为例:

 postqueue -p -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- A78C42189B1 2523 Thu Jul 25 14:53:57 [email protected] (connect to tellia.com[141.8.224.25]:25: Connection timed out) [email protected] -- 2 Kbytes in 1 Request. 

我想selectupp A78C42189B1 ,并将地址[email protected]更改为[email protected]

到目前为止,我发现我可以:

  1. 使用postcat -q A78C42189B1我可以得到一个排队项目的副本
  2. 从元数据清理消息,postcat消息可能看起来像:

     *** ENVELOPE RECORDS deferred/A/A78C42189B1 *** message_size: 2523 248 2 0 2523 message_arrival_time: Thu Jul 25 14:53:57 2013 create_time: Thu Jul 25 14:53:57 2013 named_attribute: rewrite_context=local sender_fullname: nobody sender: FROM:[email protected] original_recipient: [email protected] recipient: [email protected] *** MESSAGE CONTENTS deferred/A/A78C42189B1 *** mail headers... mail body... *** HEADER EXTRACTED deferred/A/A78C42189B1 *** named_attribute: notify_flags=1 original_recipient: [email protected] done_recipient: [email protected] *** MESSAGE FILE END deferred/A/A78C42189B1 *** 

    清理后缀页眉和页脚,因此只有邮件标题和邮件正文留在文件中,使用文本编辑器或sed。

  3. 使用sendmail将邮件发送到新的收件人

     sendmail [email protected] < edited_mail_file 
  4. 从队列postsuper -d mailID邮件postsuper -d mailID删除原始邮件

如果有人用sed-skills,可以剪出邮件头和身体,这3个第一步应该可以pipe住

是的,您描述的方法正在处理邮件卡在邮件队列中。

虽然对于您的具体问题并不是一个真正的答案,但是我想分享一下我做的(重新)解决一些常见拼写错误的域名,使用您的提示:

在postfix / main.cf中:

 recipient_canonical_maps = regexp:/etc/postfix/maps/recipient_canonical 

文件/ etc / postfix / maps / recipient_canonical:

 /^(.*@)htomail.com$/ ${1}hotmail.com /^(.*@)homail.com$/ ${1}hotmail.com /^(.*@)hotmai.com$/ ${1}hotmail.com /^(.*@)hotmai.co$/ ${1}hotmail.com /^(.*@)hotma.com$/ ${1}hotmail.com /^(.*@)gmial.com$/ ${1}gmail.com /^(.*@)gmail.co$/ ${1}gmail.com /^(.*@)gmail.nl$/ ${1}gmail.com