使用regex拆分错误eml

2024-09-27 19:28:59 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我有一份未送达的报告,如图所示。我想用regex解析这些。你知道吗

(<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"

Tags: thetonamefromcomhostremoteexample

热门问题