SMTP and it’s Applications

本文介绍了电子邮件系统的基本组成部分,包括MTA、MDA和MUA的功能,以及SMTP、POP3和IMAP等关键协议的工作原理。此外还探讨了MIME编码如何解决非文本数据的传输问题,并简述了C#中SMTP的支持情况及POP3接收邮件的方法。
e-mail model:
几乎所有的互联网邮件系统应用Unix E-Mail模型。Unix E-Mail模型把E-Mail功能分成三部分:
MTA(Message Transfer Agent),负责发送和接收邮件。
MDA(Message Delivery Agent),负责向本地系统的邮件用户分派邮件。
MUA(Message User Agent),负责从远程访问邮箱服务器。
 
相关协议:
SMTP(Simple Mail Transfer Protocol),是用来邮件传输的协议。
 
POP3(Post Office Protcol, Version 3),是用来访问邮件服务器,接收邮件的协议。
 
IMAP(Interactive Mail Access Protocol),同POP3一样用来访问邮件服务器,但方式不一样,POP3将邮件下载到本地,IMAP可以不用下载到本地,用户可以在服务器建立文件夹,收邮件,邮件存放在服务器。

MIME(Multipurpose Internet Mail Extentions),因为 SMTP 只能传送文本,在传送附件这样的二进制类型的时候需要编码。有一种是 uuencode ,是 UNIX 下常用的编码方式,但最常用的是 MIME MIME 包括几种编码方式,其中有最常用的 base64 编码方式。

 
C#对SMTP 的支持:( 包装了原有的Windows组件)
C#提供了SmtpMail,MailMessage,MailAttachment等类来简化邮件发送过程。发送邮件需要SMTP Server。(试验SmtpMail类的话,或者本地有SMTP Server, 或者有SMTP Server中转。一般SMTP Server不是中转所有发往它,而目标地址又不是它的邮件,这样的话,容易被滥用,而导致垃圾邮件,需要一定的权限机制。FoxMail这样的软件发邮件时是如何工作的呢?)
 
用POP3接收邮件
POP3邮件服务器的服务端口是110。Client通过发送文本命令到POP3服务器,然后得到响应的方式接收邮件。常用命令有USER(指定用户名),PASS(指定用户密码),STAT(统计有多少有件和邮件占用空间),LIST(列表),TOP(得到某条邮件的头信息),RETR(返回某条邮件的数据)。可以用Telnet命令的方式收邮件。用C#编程的方法可以先建立一个Tcp连接,然后用StreamWriter,StreamReader发送命令得到响应,模拟Telnet过程。(即使2进制数据在邮件的发送过程中也都转换成了可视字符,想正确得到所有内容,还需要解码,对于支持html的内容显示成相应的格式等).
 
【实验内容】 1. 2. 3. Analyze the real-world Email transfer scenarios that you could very possibly encounter on a daily basis. Analyze the SMTP and MIME Analyze the POP or IMAP 【实验步骤】 一、 Analyze Normal SMTP Communications SMTP uses Sender-SMTP and Receiver-SMTP processes. By default, SMTP communications are not secure. The default port used for SMTP communications is port 25, however SMTP can (like many applications) be configured to run over another port number. Do the following: • Use the zip file lab-wireshark-traces.zip and extract the packet trace file smtp-normal.pcapng • Open the capture file in Wireshark The SMTP client sends the MAIL FROM and provides its source email address to the SMTP server. This address must be approved by the SMTP server. Next the client sends a RCPT TO indicating who the email will be destined to as shown in Figure 8.1. The DATA command indicates the client is ready to send the email, and if the server is ready it responds with 354 Start Mail Input. Now the client can send the email to the SMTP server. Once the email is sent, the client issues the QUIT command to close the connection termination process. Figure 8.1 Normal SMTP This is a pretty short communication, but there is a point where things are slow. {实验问答} 1. What is the IP address and TCP port used by the client which is sending the email? 2. What is the IP address and the TCP ports used by the SMTP server? 3. Who sent the email? Who receives the email? 4. Can you read the email meaage? Is the email message in plaintext or ciphertext? Is SMTP a secure transfer 1 网络协议实验教程 protocol? (Hint: 追踪 TCP 流) 5. How many requests command to send by client? What are they?(Hint: filter of smtp.req.command) 6. Based on the Time column, who is slowing things down(client or server issue)? 二、 Analyze Normal POP Communications Do the following: • Use the zip file lab-wireshark-traces.zip and extract the packet trace file pop-normal.pcapng • Open the capture file in Wireshark This trace depicts a normal POP communication like figure 8.2. Figure 8.2 A user retrieves one email message The POP user provides their username and password. The POP server opens the mailbox and tells the user that one message is waiting (the message is 11,110 bytes long). The client asks for the Unique Identification Listing (UIDL) before issuing the RETR command and the POP server begins sending the data to the client over multiple TCP packets if necessary. Upon successful download of the email message, the client sends the delete command (DELE). The server responds indicating it has deleted the message. POP does not maintain a persistent connection—the connection is established to retrieve the email and then terminated upon successful completion. {实验问答} 7. What the user does in the trace? (Hint: filter of pop.request) 8. Whose mail box is being accessed? 9. How many email messages did the user retrieve? 10. Outline the details of email which are in the Inbox 11. Did the user delete the message after picking it up from the POP server? 12. Did you see any slow behavior in this trace? If so, is there a slow network, client or server issue? 13. Who terminated the POP communications? Server or client? Why? 三、 Analyze POP Problems Do the following: • Use the zip file lab-wireshark-traces.zip and extract the packet trace file pop-spamclog.pcapng • Open the capture file in Wireshark 2 网络协议实验教程 Spam clogged mailboxes can also affect performance. In Figure 8.3 we are looking at the email download process for a client whose mailbox is filled with spam messages. Each spam message has a binary attachment (a .pif file in this case). The client complained because downloading email seemed to take an extremely long time (over 30 minutes). The user did not complain about spam, however. Figure 8.3 SPAM messages clog an inbox—email retrieval takes over 30 minutes Examining the user’s email retrieval process shows the spam messages and the attachments. Hundreds of these emails were being transferred to the user when they retrieved their email. Most of the spam messages were automatically moved to the user’s spam folder (hence their lack of awareness regarding the high quantity of spam being retrieved). The spam retrieval process was slowing down the retrieval of good email traffic. More aggressive spam filtering should be applied at the POP server. By looking at the information in the trace file, answer the following questions. We are retrieving email and someone sent us a malicious .pif file. {实验问答} 14. What the user does in the trace file? (Hint: filter of pop.request) 15. Which packet contains the name of the pif file?
最新发布
05-11
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值