




已阅读5页,还剩14页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
0外文原文ResearchandDevelopmentofE-mailProgramBasedonJavaAbstractThispaperanalyzestheworkingprincipleofthemailsystem,researchesanddevelopsonthethreecoremodulesofanE-mailsystemE-mailsendingmodule,E-mailreceivingmodule,E-mailanalysisanddisplaymodule,andachievesthecorefunctionofanE-mailsystemusingJavalanguage.Keywords-Java;E-mail;SMTP;POP3;IMAP;MIMEI.INTRODUCTIONWiththecomputerandInternettechnologysdevelopment,e-mailhasbecomeanessentialtoolforlife.Itssimpleuse,rapiddelivery,low-cost,easypreservation,includingattachmentsandsmoothintheworldhasgreatlyimprovedthewayofpeoplesexchange.Thecorefeaturesofane-mailsystemincludee-mailsending,e-mailreceivingande-mailanalysis.So,thedevelopmentofe-mailsystemisdifficultandcomplex.Anemailsystemismostlyacommercialsoftware,whosecodeandrealizationisexternalconfidential.Thus,itspricesareextremelyexpensive.Inordertopromotethee-mailtechnologysopensourceandsharing,alotofexperimentsaimingatthedevelopmentofthee-mailsystemweredone,andthecorefunctionaimingatthee-mailsystemwasalsoanalyzedandelaboratedinthisarticle,hopingtochangee-mailsystemsintofreeopensourcesoftwareearly,justlikeLinux.II.THEWORKINGPRINCIPLEOFE-MAILThee-mailstransmissionisaresultofcollaborativeworkamongmailclientprogram,SMTPserver,DNSserverandPOP3/IMAPserver1.Understandingtheworkingprincipleofe-mailisthebasisofe-mailprogramdevelopment.A.MailTransferProtocolThee-mailneedstobetransmittedbetweenmailclientsoftwareandmailserversoftware,aswellasbetweenthetwomailservers.Thee-maildeliverymustfollowcertainruleswhicharecalled“MailTransferProtocol”2.TheyaredefinedinRFCdocumentsas1follows:SMTPProtocolItsfullnameisSimpleMailTransferProtocol,whichdefinesthecommunicationrulesbetweenmailclientsoftwareandSMTPserver,aswellasbetweentwoSMTPservers.POP3ProtocolItsfullnameisPostOfficeProtocol,whichdefinesthecommunicationrulesbetweenmailclientsoftwareandPOP3server.IMAPProtocolItsfullnameisInternetMessageAccessProtocol,whichalsodefinesthecommunicationrulesbetweenmailclientsoftwareandmailserver.ItisanextensionofPOP3Protocol.Allofthemailserverandthemailclientprogramarecompiledinthebasisofaboveprotocol.B.MailTransmissionProcessNow,weillustratethemailstransmissionprocessandworkingprincipletakinggoogleelectronicmailboxandsinaelectronicmailboxasanexample.Assumingthatanaccountofsinamailboxisfangxinglv_1andanaccountofsohumailboxisfangxinglv_2,theysendandreceivemailasfigure1.Thesolidlinesinfigure1representthatfangxinglv_1accountsendamailtofangxinglv_2account.While,thedottedlinesrepresentthatfangxinglv_1accountsendamailtofangxinglv_2account.Now,wespeciallyexplainalltheinvolvedstepsfromamailsendingtoitsreceivingbyanalyzingtheprocessthatfangxinglv_1accountsendamailtofangxinglv_2account.2Figure1.Theschematicdiagramofmailsendingandreceivingprocess1)Themailclientprogramoffangxinglv_1accountestablishednetworkconnectiontosinasSMTPserver.Usingfangxinglv_1susernameandpassword,peoplecanloginthesystemsuccessfully.Afterthat,themailissenttosinasSMTPserverbySMTPprotocol.2)AftertheSMTPserverofsinareceivedthee-mailfangxinglv_1submitted,itdeterminedwhetherthemailaddressofreceiverisbelongtothejurisdictionofitsSMTPserveraccordingtothesuffixofreceiversmailaddressfirstly.Ifitis,themailisdirectlystoredtothemailboxofreceiver.Otherwise,theSMTPserverofsinaqueriesthedomainnameMXrecordsexpressedbythereceiverse-mailaddresssuffix()totheDNSserver.So,theinformationofsohusSMTPserverisobtained.TheconnectiontosohusSMTPserverisestablished.Now,themailissenttosohusSMTPserver.3)AftersohusSMTPserverreceivese-mailfromsinasSMTPserver,italsoneedtodeterminedwhetherthemailisbelongtothejurisdictionoftheSMTPserveraccordingtothemailaddressofreceiver.Ifitis,themailisdirectlystoredtothemailboxofreceiver.Otherwise,(Normallyitwillnothappen),theSMTPserverofsohuwillcontinuousforwardthise-mail,oritwilldiscardthise-mail.4)Theuserwhoowesfangxinglv_1accountestablishesnetworkconnectiontothePOP3/IMAPserverofsohubymailclientprogram.Usingfangxinglv_1susernameandpassword,peoplecanloginthesystemsuccessfully.Now,theusercan3checkwhetherthereisanewmailinthefangxinglv_2accountbyPOP3/IMAPprotocol.Ifthereis,themailcanbereadbyPOP3/IMAPprotocol.III.MAILSENDINGPROGRAMWhenwereceiveane-mail,themailissentfromtheSMTPserverofthismailaccount.AndthemailissenttotheSMTPserverofthereceiverbytheaddressofthereceiver.A.TheArchitectureofMailSendingAPIJavaMailAPIdefinesajava.mail.Transportclass,whichisdedicatedtotheimplementationofe-mailtask.Itsinstanceobjectsencapsulatethebottomimplementationdetailsofsomemailsendingprotocol.Whenapplicationprogramsinvokethemethodofthisclass,themaildataencapsulatedinMessageObjectissenttotheappointedSMTPserver.TheworkrelationofmainAPIsinvolvedinsendingmailbyJavaMailisexpressedinthefollowingfigure.Figure2.TheworkrelationofJavaMailAPIsinsendingmail1)Obtainandachieveatransportobjectofcertaine-mailsendingprotocolsfromtheSessionobject.2)UsetheSessionobjecttocreateaMessageobject,andinvokemethodsoftheMessageobjecttoencapsulatemessagedatas.3)ConnectthespecifiedSMTPserver,andsendthemaildataencapsulatedinMessageObjectusingthemailsendingmethodintheTransportobject.Intheprocessofcompilingthemailsendingprogram,wequerytheinformationofDNSbyJNDI,whichistheEnglishabbreviationofJavaNamingandDirectoryInterface.ItisanAPI(ApplicationProgrammingInterface)providingnaminganddirectoryaccessingforJAVAapplicationprogram.B.TheMailSendingProgramwithSMTPServerTheso-calledmailsendingprogramhasSMTPserverfunction.ItisbecausethattheprogramitselfcandirectlysendmailexternallyasaSMTPserver.Itdoesntneedtorelyon4otherSMTPserverstosendproceduresexternally.TheprimarytaskofcompilingmailsendingprogramwhichhasSMTPserverfunctionistobeabletoobtainthenameofitsSMTPserveraccordingtotheaddressofreceiver.ThatistheMXrecordsofreceiversdomaincanbequeriedinDNSserver,andtheSMTPserversnameoftheMXrecordscanbeanalyzed.AfterobtainingthenameoftheSMTPserverwhichcontainstheaddressofthereceiver,theapplicationprogrammingcandirectlyconnecttothisSMTPservertosendmails,andsendingmailsdoesnotrequireuserauthentication.ThecorecodeachievingSMTPserverprogramiscomposedofthefollowingcomponents:1)Setuptheaddressofmultiplereceiversthemailwillbemasssentto.Stringto=“UserName1SeverN”,“UserName2ServerN”,2)CreatetheSessionObjectPropertiesprops=newProperties();props.setProperty(“mail.smtp.localhost”,”mail.MySmtpServerN”);Sessonsession=Session.getInstance(props);session.setDebug(true);Messagemsg=createMessage(session);for(inti=0;i”);catch(MessagingExceptione)e.printStackTrace();2)CompiletheSerlvetsourceprogram,andplacethecompiledclassfiletothedirectorywebappsreceivesMailWEB-INFclasses.ThenaddthemappinginformationofMsgInfointheweb.xmlfile.3)StarttheTomcatserver,andopentheIEbrowser,thenentertheURL“http:/localhost:8080/receivesMail/MsgInfo”fortesting.D.SearchingE-mailJavaMaildefinesaclassnamedSearchTerminjavax.mail.searchpackagetocreatesearchconditions.AfterapplicationcreatestheobjectofSearchTermclass,itcancallFolder.searchmethodtosearchalltheE-mailswhichaccordwiththesearchconditions.V.THEANALYSISANDDISPLAYOFE-MAILAnalyzinganddisplayinganE-mailmeansanalyzingthedatawhichwasencapsulatedinMessageobject.ThesedatacontainstheaddressoftheE-mailsenderintheE-mailhead,theE-mailsubject,thesendingtime,thetextinformationintheE-mailtext,theresourcesembedded,themailattachmentsandsoon,andthenthesedataissenttodatadisplayingsoftwaretodisplay.A.TheOrganizationStructureofMIMEE-mailMIMEprotocolisusedtodefinetheformatofcomplexEmailbody.Itcanexpressanumberoftextornon-textcontent.Inaddition,thedataformataccordedwithMIMEprotocolcanavoidtheinformationlossintransmissionProcess.So,anEmailusingMIMEprotocolcalledMIMEE-mail.AMIMEE-mailcanbecombinedbymanykindsofMIMEmessages.AMIMEmessage10representsabasicMIMEresourceoracombinationofseveralbasicMIMEmessages.EachMIMEmessageincludestwopartscalledtheheadandthebody.Inwhich,theMIMEmessagebodycontainsthespecificcontentoftheresources,andtheMIMEheadercontainsthedescriptioninformationofresources.SomeMIMEmessageinthesamelevelmustbecombinedintoaMIMEcombinationmessage,andtheyareusedasthebodyofMIMEcombinationmessagetogether.Theyareseparatedbysomeseparatedidentifiers,andthetypesandtheseparatedidentifiersofthecombinationmustbedescribedinthemessageheadofMIMEcombinationmessage.AMIMEcombinationmessagecanalsocombinewithotherMIMEmessagetoformalargerMIMEcombinationmessage.Thus,theyhaveformedamultilayernestedcombinationrelation.AMIMEE-mailisthemosttop-levelMIMEcombinationmessageformedinthiscombinationmode.TheMIMEprotocolcanexpresscomplexcontentsinthismultilayercombinationmode5.TherearethreecombinationrelationshipsamongtheMIMEmessagesinaMIMEE-mail:mixed,related,andalternative.AndtheircorrespondingMIMEtypesareinthefollowing:multipart/mixedItrepresentsthetypeofthecontentinthemessagebodyismixedcombinationtype.Thecontentcanbeamixingbodywhichcontainstext,audioattachmentandsoon.multipart/relatedItrepresentsthetypeofthecontentinthemessagebodyisrelatedcombinationtype.Inwhich,someresourcesarerelatedtootherresources.multipart/alternativeItrepresentsthetypeofthecontentinthemessagebodyisalternativecombinationtype.Forexample,whenthemaintextofanE-mailisexpressedbybothHTMLformatandconventionaltextformat,thetwoformattextcanbenestedinaMIMEcombinationmessageofmultipart/alternativetype.Theadvantageofthismethodisthatthetextformatamongthemcanreplaceit,iftheE-mailreadingprogramdoesnotsupporttheHTMLformat.11ThebasicsituationofthemostcomplicatedE-mailis:containingE-mailbodyandattachments.ThemaintextoftheE-mailcanbeexpressedbybothHTMLformatandconventionaltextformat.AndsomeembeddedresourcesarerelatedintheHTMLformattext.TheMIMEmessagestructureofthiskindofE-mailcanbedescribedinthefollowingfigure.Figure5.TheMIMEmessagestructureofthecomplicatedE-mailB.TheFlowofJavaMailAnalyzingE-mail1)ObtaintheinformationoftheE-mail,suchasthesubjectoftheE-mailandsenderoftheE-mail,bycallingthegetFrommethodandthegetSubjectmethodinMessageobject.GettheE-mailtypebythegetContentTypemethod.2)JudgethetypeoftheE-mailcanaccordingtothereturnvalueoftheMessage.getContentTypemethod.AndobtainthecontentoftheE-mailbycallingtheMessage.getContentmethod.IfthetypeoftheE-mailis“text/plain”or“text/html”,itexpressesthetypeoftheE-mailispuretext.ThecontentoftheE-mailcanbeobtainedbycallingthegetContentmethodinMessageobject.ThenconvertthetypeofthereturnobjecttoStringtypeandoutputittothedisplaysoftware.IfthetypeoftheE-mailis“mutlipart/*”,itexpressesThecontentoftheE-mailiscompoundtype,thenweneedtoconvertthetypeofthereturnobjecttoMultiparttype.3)DetectthenumberofBodyPartobjectsencapsulatedintheMultipartobjectbycallingthegetCountmethodintheMultipartobject,andthenfetchandprocesseachBodyPartobjectinMutlipartobjectonebyonebyusingforcycle.VI.CONCLUSIONAcompleteE-mailsystemhasalargescale,becauseofthelimitedspace,thispaper12onlyrealizedthecorefunctionsofusingJavalanguagebasedonSMTPprotocol,POP3/IMAPprotocol,andMIMEprotocol.13外文翻译基于Java的电子邮件程序的研究和开发摘要:本文分析了电子邮件系统的工作原理,研究和发展了E-mail系统的发送模块,接收模块,分析和显示三个核心模块,并实现使用Java语言实现电子邮件系统的核心功能。关键词:Java;E-mail;SMTP;POP3;IMAP;MIMEI.引言随着计算机和互联网技术的发展,电子邮件已经成为生活中不可或缺的工具。它使用简单,发送迅速,成本低,易保存,可以包括附件,大大提高了人们的交流方式。电子邮件系统的核心功能包括邮件发送,邮件接收和邮件分析。因此,电子邮件系统的开发是困难和复杂的。一个电子邮件系统主要是一个商业软件,其代码和实现对外部保密。因此,它的价格是非常昂贵的。为了促进电子邮件技术的开源和共享,已经在电子邮件系统上做了大量的实验,本文将对电子邮件系统的核心功能进行分析,希望变电子邮件系统为免费的开源软件,就像早期的Linux操作系统。II.电子邮件的工作原理电子邮件的传输是邮件客户端程序,SMTP服务器,DNS服务器和POP3/IMAP服务器协同工作的结果。了解电子邮件的工作原理是电子邮件程序开发的基础。A邮件传输协议电子邮件需要被邮件客户端软件和邮件服务器软件,以及两个邮件服务器之间发送。该电子邮件传递必须遵循一定的规则,被称为“邮件传输协议”2。它们是在RFC文档定义如下:SMTP协议它的全称是简单邮件传输协议,它定义了邮件客户端软件和SMTP服务器,以及两个SMTP服务器之间的通信规则。POP3协议它的全称是邮局协议,它定义了邮件客户端软件和POP3服务器之间的通信规则。IMAP协议它的全称是Internet消息访问协议,这也定义了邮件客户端软件和邮件服务器之间的通信规则。它是POP3协议的扩展。上述协议是所有的邮件服务器和邮件客户端程序被编译的基础。B邮件传输过程现在,我们说明一下邮件的传输过程和工作原理,我们用搜狐电子邮箱和新浪电子邮箱作为一个例子。假设新浪邮箱的帐户fangxinglv_1和搜狐邮箱的帐户fangxinglv_2,他们发送和接收邮件如图一。图1中的实线代表从fangxinglv_1帐户发送邮件到fangxinglv_2帐户。同时,虚线代表从fangxinglv_2帐户发送邮件到fangxinglv_1帐户。现在,我们特地解释从fangxinglv_1帐户发送邮件到fangxinglv_2帐户的过程中邮件发送其接收所有相关步骤。141)fangxinglv_1帐户的邮件客户端程序建立到新浪的SMTP服务器的网络链接。使用fangxinglv_1的用户名和密码登录系统。在此之后,该邮件是由SMTP协议发送到新浪的SMTP服务器。2)在新浪的SMTP服务器收到提交的电子邮件fangxinglv_1,它确定是否接收的邮件地址是按照先接收方的邮件地址后缀属于它的SMTP服务器的司法管辖区。如果是,则该电子邮件被直接存储到接收器的邮箱。否则,新浪的SMTP服务器查询所接收的电子邮件地址后缀()到DNS服务器所表示的域名的MX记录。因此,获得搜狐的SMTP服务器的信息。要与搜狐的SMTP服务器建立链接。现在,该邮件被发送到搜狐的SMTP服务器。3)搜狐的SMTP服务器从新浪的SMTP服务器接收电子邮件后,还需要根据接收者的邮件地址的邮件判断是否属于SMTP服务器的司法管辖区。如果是,则该电子邮件被直接存储到接收器的邮箱。否则,(一般情况下也不会发生),搜狐的SMTP服务器将连续转发这个邮件,否则将丢弃此电子邮件。4)使用fangxinglv_1帐户的用户建立了从邮件客户端程序到搜狐的POP3/IMAP服务器的网络连接后,使用fangxinglv_1的用户名和密码登录成功。现在,用户可以检查是否有新邮件在fangxinglv_2账户通过POP3/IMAP协议。如果有,该邮件可以通过POP3/IMAP协议来读取。III.邮件发送程序当我们收到一封电子邮件时,该邮件从发送方的SMTP服务器发送给接收方的SMTP服务器的。A.JavaMailAPI定义了一个java.mail.Transport类,它是专门用来完成发送电子邮件。它的实例对象封装了一些邮件发送协议的底部实现细节。应用程序调用该类将封装在MessageObject的邮件数据发送到指定的SMTP服务器。涉及通过JavaMail的发送邮件的主要API的工作关系是体现在如图2所示。1)从会话对象中获得和实现运输对象的某些电子邮件发送协议。2)使用会话对象来创建一个消息对象,并调用消息对象来封装消息数据的方法。3)连接指定的SMTP传输对象服务器,使用邮件传输协议将邮件封装起来进行发送。编译邮件发送程序的过程中,我们通过JNDI查询DNS的信息,这是Java命名和目录接口的英文缩写。这是一个API(应用程序编程接口)为JAVA应用程序提供命名和目录访问。B邮件发送程序和SMTP服务器所谓的邮件发送程序SMTP服务器。因为程序本身可以直接发送邮件外部SMTP服务器,它不需要依靠其他SMTP服务器。SMTP服务器主要功能是要能够根据接收方的地址获取其SMTP服务器的名称。这是接收器的域的MX记录,可以在DNS服务器上进行查询和分析。获得包含接收者的地址的SMTP服务器的名称后,应用程序编程可以直接连接到该SMTP服务器发送邮件,发送邮件并不需要用户身份验证。核心代码实现的SMTP服务器程序是由以下几部分组成:1)设置多个接收者的邮件将被大规模发送到的地址。Stringto=“UserName1SeverN”,“UserName2ServerN”,2)创建会话对象属性道具=新的属性();Propertiesprops=newProperties();15props.setProperty(“mail.smtp.localhost”,“mail.MySmtpServerN”);Sessonsession=Session.getInstance(props);session.setDebug(true);Messagemsg=createMessage(session);for(inti=0;i”);catch(MessagingExceptione)e.printStackTrace();2)编译Serlvet源程序,然后将编译后的class文件到目录webappsreceivesMailWEB-INFclasses再在web.xml文件中加入MsgInfo的映射信息。3)启动Tomcat服务器,打开IE浏览器,然后输入网址“http:/localhost:8080/receivesMail/MsgInfo”进行测试。D搜索E-mailJavaMail在javax.mail.search包中定义
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医院感染与质量管理
- 肥胖生殖无能综合征知识科普2025
- 2025届高考物理大一轮复习课件 第九章 第43课时 电场能的性质
- 小儿高热惊厥的处置
- AI大模型SaaS平台设计方案
- 小儿肺炎试题单选及答案
- 烯烃炔烃试题及答案
- 河南省青桐鸣2024-2025学年高二下学期5月大联考地理试卷(含答案)
- 2025年陕西省榆林市榆阳区中考二模历史试题(含答案)
- 配电箱跨接导线锈蚀排查
- 电镀加工合同协议
- 国开2024年《测量学》形考任务1234答案全析
- 非营利组织项目申请书范文
- 2025年军队文职人员(司机岗)历年考试真题库及答案(重点300题)
- 2025-2030CAPP软件行业市场深度调研及发展现状趋势与投资前景研究报告
- Windows 故障转移群集功能实现高可用的文件服务器
- 水库清淤工程安全措施
- 2024年全球及中国5G工业网关CPE行业头部企业市场占有率及排名调研报告
- 商业模式创新试题及答案
- 旅行跟拍合同及服务条款
- 手术患者深静脉血栓预防措施
评论
0/150
提交评论