嗨,我有一个未送达的报告,如图所示。我想用正则表达式解析这些。
(<from:.* to:.*>)([\w\W]*)
给了我第一个如何拆分为 3 封电子邮件并仅获取详细信息部分的信息。
.....
.....
bhahbhahbhahbhahbhahbhahbhahbhahbhahbhahbhah.....
Message-Id: <example@example.com>
This is the mail gateway at gw.example.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.
<name.surname@gmail.com>:
<from:example@example.com to:name.surname@gmail.com> 123.123.11.22 does not like recipient
Remote host said: 550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 asd123123.123 - gsmtp
Giving up on 123.123.11.22.
<name.surname@hotmail.com>:
<from:example@example.com to:name.surname@hotmail.com> 21.32.54.65 does not like recipient
Remote host said: 550 Requested action not taken: mailbox unavailable
Giving up on 21.32.54.65.
<name.surname@ymail.com>:
<from:example@example.com to:name.surname@ymail.com> <from:example@example.com to:name.surname@ymail.com> D12.123.12.12 failed after I sent the message.
Remote host said: 554 delivery error: dd This user doesn't have a ymail.com account (name.surname@ymail.com) [0] - mta123.mail.ne1.yahoo.com
--- Below this line is a copy of the message.
Return-Path:
bhahbhahbhahbhahbhahbhahbhahbhahbhahbhahbhah.....
....
....
预期输出:
1: "123.123.11.22 does not like recipient\n Remote host said: 550-5.1.1 The email account that you tried to reach does not exist. Please try\n 550-5.1.1 double-checking the recipient's email address for typos or\n 550-5.1.1 unnecessary spaces. Learn more at\n 550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 asd123123.123 - gsmtp\n Giving up on 123.123.11.22.",
2: '21.32.54.65 does not like recipient\n Remote host said: 550 Requested action not taken: mailbox unavailable\n Giving up on 21.32.54.65.',
3: "D12.123.12.12 failed after I sent the message.\n Remote host said: 554 delivery error: dd This user doesn't have a ymail.com account (name.surname@ymail.com) [0] - mta123.mail.ne1.yahoo.com"