Use javamail to receive hotmail bounce messages

Source: Internet
Author: User
Hotmail is my most commonly used Email Client. Although the size of hotmail is a little small nowadays, the speed is often slow, so people can not help but greet Gates mother. However, it is undeniable that it is quite rich and stable. In particular, its page design is an important reference for web programmers.
Unlike many POP3 servers, hotmail provides message transmission status notifications (multipart/report ). I previously wrote that the mail client only supports receiving multipart/related, multipart/alternative, multipart/mixed, and other multimedia types of mail. Others are ignored because they are not common.
If the customer does not agree, what else can be said? What is more important than making the customer satisfied? Before the bill is paid.

For details about multipart/report Mail types, see RFC1892. Sun's Chinese Javamail Faq also provides relevant instructions. The following is an excerpt:
Q. When a message cannot be sent, a failure message is returned. How can I detect these "bounce" messages?
A: Although there is an Internet standard used to report such errors (for the multipart/report MIME type, see RFC1892), it has not been widely implemented yet. RFC1211 discussed this issue in depth, including a large number of examples.
In Internet email, whether a specific mailbox or user name exists can only be determined by the final server that sends the message. Messages may pass through several relay servers (they cannot detect errors) and then reach the final server. Generally, when the server detects this error, it returns a message to the sender of the original message, indicating the cause of the failure. Many Internet standards have discussed Delivery Status Notifications, but many servers do not support these new standards. Instead, they use special techniques to return such error messages. This makes it very difficult to associate the "rebound" message with the original message that generates the problem (note that this problem is completely irrelevant to JavaMail ).
There are a lot of techniques and testing methods to deal with this problem, but they are not perfect. One technique is Variable Envelope Return Paths, which is described by the http://cr.yp.to/proto/verp.txt.
I modified the program and simply processed it. The code is as follows:
Private void parseMultipart (Multipart multipart) throws Exception {
For (int I = 0, n = multipart. getCount (); I <n; I ++ ){
BodyPart part = multipart. getBodyPart (I );
String disposition = part. getDisposition ();
If (part. isMimeType ("multipart /*")){
This. parseMultipart (Multipart) part. getContent ());
} Else if (part. isMimeType ("text/html ")){

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.