Hotmail is my most commonly used EmailClient. 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 implements message delivery status notification (mult JavaMailHotmail ).
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 ")){
// Process text content
}
/******* Process attachments, images, and so on ********/
} Else if (part. isMimeType ("message/delivery-status ")){
Part. setFileName ("details.txt"); // The content of details.txt, which is the mail header information of the status notification.
SaveAttachedFile (part );
} Else if (part. isMimeType ("message/rfc822 ")){
MimeBodyPart mbp = new MimeBodyPart (part. getInputStream ());
Part. setFileName (mbp. getHeader ("Subject", null) + ". eml"); // use the return title as the file name in the format of outlook.
SaveAttachedFile (part );
}
}
}
To be more friendly, you can also make many improvements, such as finding the original in the sent folder based on the bounce message, or initiating a notification event. Customers don't need it. I still don't have to be passionate about it.
As we all know, hotmail uses the webdav protocol instead of the pop3 protocol. Use java to send and receive hotmail emails. For more information, see accessing Hotmail through JavaMail.