一个简单的邮件收发程序

1. Background

My company decided to use Open Office instead of Ms Office several months ago. Because there is no mail sofware in Open Office, I decided to develop a mail program myself. Finally, my company decided to use Lotus Notes for receiving mails and forbade the port for pop3. Thus, my program doesn't make much sense. Indeed, it needs much work to develop a mail client with high performance. Since I am not so free, I quited after I implemented the basic functions, such as, send a mail and receive mails. I upload my code at http://download.csdn.net/source/1203159.

 

Here, I describe my design briefly. There are two modules, one for sending and receiving mails----SimpleMail, one for caching the mails received---FileStore.

 

2. Reference

Obviously, you need to be familiar with the related mail protocols, such as Smtp and Pop3. The RFC documents present the basic knowledge. The RFC 821, 822, 1939 may be the first three that you should read.

 

3. SimpleMail

The module, SimpleMail, is reponsible for sending and receiving mails. I adopt a layered architecture, though it is so simple. Of course, the layer on the top is for user interface, while the layer at the bottom is responsible for handling the network protocols. The layer in the middle is to hide the detail of the network protocol, and provides the upper layer with fixed interface. As shown in the project, I devided the files into three filters.  The filter named view contains files for user interface. Besides, the other two filters are for Smtp and Pop3 respectively, and they are the principal protocols. The file --MailManager--that is outside the filter comprises the middle layer, which acts as an intermediary between the user interface and the network protocol. Here, I list the interface in the MailManager below which characterizes the main functions of the mail program :

  

3.1 the View part

However, I think the implementation intended for user interface doesn't need much description. They are mostly commonplace.  But there is an edit box in the send mail dialog. You can drag files into it and select the files in it to delete them. Well, that costed me much time to accomplish those functions. It's worth for you to read it.

 

3.2 the Mail part

Well, the files in connection with the network protocols may refer to some background knowledge.  In fact, those implementation just follow the protocols. Here, I only explain the purpose of several files.

PopReceiveManager.h---implement pop3 protocol for receiving mails

SmtpSendManager.h---implement smtp protocol for sending mails

MIMECode.h, Base64.h---encode and decode the mail content, mainly use the base64 algorithm

AppOctetStream.h, MIMEContentAgent.h, Textplain.h---follow the mail format--MIME

 

4. FileStore

Well, it's necessary to cache the mails received for further use. So I develop this module for that purpose. The design is similiar to the way that the operating system constructs the files system. The basic unit is a block that stores a mail. And a certain number of blocks comprise a heap while a certain number of heaps comprise a cluster. All of these in this hierachical has an according sturcture to store some related information. The block index indicates the position of the mail.  And the header at the head of the file stores the start position to store the mails. The following is the key structures.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值