JavaMailHotmail
Hotmail 是我最常用的Email Client。虽然时下hotmail的容量是小了些,速度也常常慢得让人不禁问候盖茨的母亲。但不可否认,它功能相当丰富,也比较稳定。尤其它的页面设计更是我等web编程人员的重要参照。
不象很多的POP3服务器,hotmail 实现了邮件传送状态通知(multipart/report)。我以前写的邮件客户端只支持收取 multipart/related、multipart/alternative和multipart/mixed 等多媒体类型的邮件,其他的因为不常见,我都忽略了。
客户不答应了,那还有什么好说的,还有什么比让客户满意更重要的事情呢,在没买单之前。
multipart/report 邮件类型的介绍参见 RFC1892,Sun的中文 Javamail Faq 里也有相关的说明,我摘录如下:
问. 当消息不能被传送时,就会返回一个失败消息。我如何检测这些“回弹”消息?
答:虽然有一个 Internet 标准用于报告这样的错误(multipart/report MIME 类型,参阅 RFC1892),但还没有广泛实现它。RFC1211 深入讨论了这个问题,包括了大量的例子。
在 Internet 电子邮件中,特定的邮箱或用户名是否存在,只能由传送消息的最终服务器决定。消息可能通过几个中继服务器(它们不能检测错误),然后再到达最终服务器。通常,当最终服务器检测到这一错误,它会返回一个消息给原始消息的发送人,指出失败的原因。有许多 Internet 标准讨论了这种传送状态通知 (Delivery Status Notifications),但大量服务器不支持这些新标准,相反使用特别技术来返回这种错误消息。这使得将“回弹”消息与产生问题的原始消息相互关联起来非常困难(注意,这个问题与 JavaMail 完全无关)。
有许多技术和试探法用于处理这一问题,但它们都不是完美的。一种技术是 Variable Envelope Return Paths,http://cr.yp.to/proto/verp.txt 描述了这一技术。
我修改了程序,也只是作了些简单的处理,代码如下:
private void parseMultipart(Multipart multipart) throws Exception {
for (int i = 0, n = multipart.getCount(); 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")) {
//处理文本内容
}
/******* 处理附件,图片等等 ********/
} else if (part.isMimeType("message/delivery-status")) {
part.setFileName("details.txt"); //仿照outlook,details.txt 内容即传送状态通知的邮件头信息
saveAttachedFile(part);
} else if (part.isMimeType("message/rfc822")) {
MimeBodyPart mbp = new MimeBodyPart(part.getInputStream());
part.setFileName(mbp.getHeader("Subject", null) + ".eml"); //仿照outlook,用退件的标题做文件名
saveAttachedFile(part);
}
}
}
如果要做得更友好,还可以做很多改进,比如根据退信找出已发送文件夹中的原件,或者激发一个通知事件等等。客户并不需要,我还是不要自作多情了。
大家都知道,hotmail 不是用pop3协议收信,而是用webdav协议。用java收发 hotmail 的邮件 ,参见《通过JavaMail访问Hotmail邮箱》。

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
