对于发送到 Postfix 服务器的电子邮件,我想要在“接收:来自”标题中记录时间戳。
例如,来自包含以下内容的电子邮件:
Received: from mailserver01 ([192.168.0.25]) by mailserver01.domain.intra with Microsoft SMTPSVC(6.5);
Mon, 16 Jul 2012 17:09:36 +0200
我想提取:
Mon, 16 Jul 2012 17:09:36 +0200
我想知道如何配置 postfix 来记录该信息(仅时区或整个“Received: from”标头)。一旦记录了该行,我就可以处理解析以提取信息。
答案1
答案2
您可以将其传递给切
echo "Received: from mailserver01 ([192.168.0.25]) by mailserver01.domain.intra with Microsoft SMTPSVC(6.5); Mon, 16 Jul 2012 17:09:36 +0200" | cut -d ";" -f 2
或者如果你将电子邮件内容放在 bash 变量中:
cat $email | grep "Received:" | cut -d ";" -f 2