Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
346 views
in Technique[技术] by (71.8m points)

php - IMAP- Parsing original headers from a bounced mail

I am sending hundreds of emails with an unique id through email header. I have to track the bounced mails for the particular unique id.

I can see the bounced emails with an attached EML file in my mailbox. Unfortunately the unique ID which I am looking for is placed in the attached EML file's header instead of bounced email's header.

I am using PHP's IMAP function to read the headers and body sections. But unable to read EML attachment.

Could any one explain how to read or parse the EML attachment using IMAP function.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The .eml is most properly described as a message/rfc822 bodypart; it comprises one part of a multipart/report.

In IMAP each bodypart has its own part number, and you can access headers and individual fields by supplying the number. In many bounces, the number of the message/rfc822 is 3, and you can access e.g. the subject using f uid fetch 123456 body.peek[3.1.header.fields (subject)]. The server will do the parsing you want and give you back the subject field.

The usual way to get the part number is to use bodystructure.

Expressing this using PHP is left as an exercise for the reader. Good luck.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...