汗,对协议不熟,小问题测试了一个晚上......
mark 匿名发邮件
Dim SMTPHoststr As String = "smtp.qq.com"
Dim data, szData
Dim namestr As String = "455189993@qq.com"
Dim passwordstr As String = "helen6849338."
Dim Senderstr As String = "455189993@qq.com"
Dim receiverStr As String = "2450314695@qq.com"
'这里定义匿名发送的别名
Dim ChangeString As String = "From: ""发件人别名"" <fanjianren@163.com> " & vbcrlf & "To: ""收件人别名"" <shoujianren@sina.com> "
Dim title = "hello,尼玛"
Dim body = "我要测试我要测试我要测试."
Dim SmtpServ As New System.Net.Sockets.TcpClient(SMTPHoststr, 25)
Dim NetStrm = SmtpServ.GetStream()
Dim RDStrm As New io.StreamReader(SmtpServ.GetStream())
Data = "HELO test" & vbcrlf
'在这里我们就默认叫server吧
szData = System.Text.Encoding.ASCII.GetBytes(Data)
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
output.show(data)
'发送要求认证命令
Data = "AUTH LOGIN " & vbCRLF
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
netStrm.Flush
output.show(data)
system.threading.thread.sleep(100)
'发送base64编码过的用户名
Dim b As Byte() = System.Text.Encoding.ASCII.GetBytes(namestr)
Dim s As String = Convert.ToBase64String(b)
Data = s & vbcrlf
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
output.show(data)
system.threading.thread.sleep(100)
'发送base64编码过的密码
b = System.Text.Encoding.ASCII.GetBytes(passwordstr)
s = Convert.ToBase64String(b)
Data = s & vbCRLF
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
output.show(data)
system.threading.thread.sleep(100)
'发送发件人信息
Data = "MAIL FROM: " & "<" & Senderstr & ">" & vbCRLF
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
output.show(data)
system.threading.thread.sleep(100)
'发送接收人信息
Data = "RCPT TO: " & "<" & receiverStr & ">" & vbCRLF
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
output.show(data)
system.threading.thread.sleep(100)
'发送Data命令
Data = "DATA" & vbCRLF
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
output.show(data)
system.threading.thread.sleep(100)
'发送数据内容 其中包括伪造的发?收件人地址和姓名;
Data = ChangeString & vbcrlf & "SUBJECT: " & title & vbcrlf & vbcrlf & body
szData = System.Text.Encoding.utf8.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
output.show(data)
system.threading.thread.sleep(100)
Data = vbCRLF & "." & vbCRLF
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
output.show(data)
system.threading.thread.sleep(100)
'退出SMTP服务器
Data = "QUIT " & vbCRLF
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
NetStrm.Write(szData, 0, szData.Length)
NetStrm.Flush()
'查看交互内容
Dim buff(10000) As Byte
netstrm.read(buff,0, buff.length)
msgbox(System.Text.Encoding.ASCII.getString(buff))
' 关闭连接
NetStrm.Close()
RDStrm.Close()
[此贴子已经被作者于2016/5/3 22:07:25编辑过]