第I页共II页目录1引言·····································································································11.1电子邮件介绍·····················································································11.2开发背景···························································································21.3开发环境及运行环境············································································22软件架构及系统用例图·············································································32.1系统架构···························································································32.2系统总体用例·····················································································32.4发送邮件类························································································42.5附加小功能类·····················································································43SMTP协议的研究····················································································43.1SMTP协议简介及工作原理···································································53.2SMTP协议的命令和应答······································································63.2.1SMTP协议的命令·········································································64RFC822·······························································································144.1RFC822简单介绍··············································································144.2信件的头部······················································································145命名控件MailSend·················································································205.1发送邮件类SmtpMail·········································································205.2AddExtra类·····················································································275.2.1调用WindowsAPI所需的命名空间··················································285.2.3在程序中具体的使用·····································································286软件运行时的界面·················································································296.1新建邮件帐号···················································································297系统测试·····························································································327.1同一SMTP服务器发送邮件的测试·······················································327.2利用不同的SMTP服务器发送邮件的测试··············································328结论···································································································34第II页共II页参考文献··································································································35第1页共36页1引言1.1电子邮件介绍电子邮件(简称E-mai1)又称电子信箱、电子邮政,它是—种用电子手段提供信息交换的通信方式。它是全球多种网络上使用最普遍的一项服务。这种非交互式的通信,加速了信息的交流及数据传送,它是—个简易、快速的方法。通过连接全世界的Internet,实现各类信号的传送、接收、存贮等处理,将邮件送到世界的各个角落。到目前为止,可以说电子邮件是Internet资源使用最多的一种服务,E-mai1不只局限于信件的传递,还可用来传递文件、声音及图形、图像等不同类型的信息。电子邮件不是一种“终端到终端”的服务,是被称为“存贮转发式”服务。这正是电子信箱系统的核心,利用存贮转发可进行非实时通信,属异步通信方式。即信件发送者可随时随地发送邮件,不要求接收者同时在场,即使对方现在不在,仍可将邮件立刻送到对方的信箱内,且存储在对方的电子邮箱中。接收者可在他认为方便的时候读取信件,不受时空限制。在这里,“发送”邮件意味着将邮件放到收件人的信箱中,而“接收”邮件则意味着从自己的信箱中读取信件,信箱实际上是由文件管理系统支持的—个实体。因为电子邮件是通过邮件服务器(mai1server)来传递档的。通常mailserver是执行多任务操作系统UNIX的计算机,它提供24小时的电子邮件服务,用户只要向mailserver管理人员申请—个信箱账号,就可使用这项快速的邮件服务。电子邮件的工作原理:1)电子邮件系统是一种新型的信息系统,是通信技术和计算机技术结合的产物。电子邮件的传输是通过电子邮件简单传输协议(SimpleMailTransferProtocol,简称SMTP)这一系统软件来完成的,它是Internet下的一种电子邮件通信协议。2)电子邮件的基本原理,是在通信网上设立“电子信箱系统”,它实际上是一个计算机系统。系统的硬件是一个高性能、大容量的计算机。硬盘作为信箱的存储介质,在硬盘上为用户分一定的存储空间作为用户的“信箱”,每位用户都有属于自己的—个电子信箱。并确定—个用户名和用户可以自己随意修改的口令。存储空间包含存放所收信件、编辑信件以及信件存盘三部分空间,用户使用口令开启自己的信箱,并进行发信、读信、编辑、转发、存档等各种操作。系统功能主要由软件实现。3)电子邮件的通信是在信箱之间进行的。用户首先开启自己的信箱,然后通过键第2页共36页入命令的方式将需要发送的邮件发到对方的信箱中。邮件在信箱之间进行传递和交换,也可以与另—个邮件系统进行传递和交换。收方在取信时,使用特定账号从信箱提取。1.2开发背景当前流行的各大邮件客户端软件的除了最主要的收发信件之外,功能越来越复杂,但是人们平常真正用到的功能很少,很多功能尤其对于那些计算机知识相对缺乏的人来说,更加显得太过于华丽而不太实用。有鉴于此,在了解RFC底层协议的基础上,我们开发了这个各种功能相对简单实用的邮件客户端程序,简化了很多不必要的功能。1.3开发环境及运行环境1.3.1开发环境AMDAthlon(TM),512M内存,80G硬盘Microsoft®Windows™XPProfessionalMicrosoft®VisualStudio2003(CSharp)Microsoft®DeveloperNetworkforVisualStudio.NET20031.3.2运行环境Intel®Pentium®2及以上处理器,32M以上内存,4G以上硬盘Microsoft®Windows™9X/NT操作系统800*600或以上的屏幕分辨率确保机器上安装有.NetFrameWork1.0或者以上版本第3页共36页2软件架构及系统用例图2.1系统架构软件的总体架构如图2.1:图2.1软件架构图2.2系统总体用例图2.2系统总体用例图2.3程序功能框图用户新建账号发送邮件接收邮件纯文本邮件带附件邮件用户主界面主要功能选择发送邮件类接收邮件类第4页共36页图2.3程序功能图2.4发送邮件类是发送邮件的核心,类名为SmtpMail,隶属于命名空间MailSend。封装了发送邮件的具体实现方法,也是具体的RFC用代码实现的过程。而用户通过具体的操作接口,接口与SmtpMail类通过交互操作来实现用户发送信件的操作。2.5附加小功能类是获取一些诸如系统时间,当前用户名,以及本机IP之类的类,类名为AddExtra,隶属于命名空间MailSend。3SMTP协议的研究由于要开发的是邮件客户端程序,就不得不用到SMTP协议和POP协议。而我个人负责的是邮件发送功能的实现,因此就必然会涉及到SMTP(SimpleMailTransferProtocol)协议。SMTP被用来在因特网上发送邮件,该协议规定了一些基本的命令和方客户端软件电子邮件接收系统电子邮件接收系统附加功能各种错误的提示简单邮件接收带有附件的邮件接收简单邮件发送带有附件的邮件发送电子邮件编写电子邮件的分类管理通讯簿管理第5页共36页法使客户端与服务器进行交互,以达到发送邮件的目的。3.1SMTP协议简介及工作原理3.1.1介绍简单邮件传输协议(SMTP)的目标是可靠高效地传送邮件,它独立于传送子系统而且仅要求一条可以保证传送数据单元顺序的通道。SMTP的一个重要特点是它能够在传送中接力传送邮件,传送服务提供了进程间通信环境(IPCE),此环境可以包括一个网络,几个网络或一个网络的子网。理解到传送系统(或IPCE)不是一对一的是很重要的。进程可能直接和其它进程通过已知的IPCE通信。邮件是一个应用程序或进程间通信。邮件可以通过连接在不同IPCE上的进程跨网络进行邮件传送。更特别的是,邮件可以通过不同网络上的主机接力式传送。3.1.2SMTP模型SMTP设计基于以下通信模型:针对用户