F
f19881021
Unregistered / Unconfirmed
GUEST, unregistred user!
用socket发送电子邮件时发生下面的错误,请问各位是什么意思
smtp error:500 error :bad syntax
源码
Private Sub Command6_Click()
winsock1.Connect Trim$("smtp.163.com", 25
m_State = MAIL_CONNECT
End Sub
Dim strServerResponse As String
Dim strResponseCode As String
Dim strDataToSend As String
winsock1.GetData strServerResponse
strResponseCode = Left(strServerResponse, 3)
If strResponseCode = "250" Or strResponseCode = "220" Or strResponseCode = "354" Then
Select Case m_State
Case MAIL_CONNECT
m_State = MAIL_HELO
strDataToSend = Trim$("f19881021@163.com"
'
'获取信箱名
strDataToSend = Left$(strDataToSend, InStr(1, strDataToSend, "@" - 1)
'向服务器发送HELO命令
winsock1.SendData "HELO " & strDataToSend & vbCrLf
'
Case MAIL_HELO
'
'改变当前进程的状态
m_State = MAIL_FROM
'
'向服务器发送 MAIL FROM命令
winsock1.SendData "MAIL FROM: " & Trim$("f19881021@163.com" & vbCrLf
Case MAIL_FROM
'
'改变当前进程的状态
m_State = MAIL_RCPTTO
'
'
winsock1.SendData "RCPT TO:" & Trim$("f19881021@163.com" & vbCrLf
'
Case MAIL_RCPTTO
'
'改变当前进程的状态
m_State = MAIL_DATA
'
'向服务器发送DATA命令
winsock1.SendData "DATA" & vbCrLf
Case MAIL_DATA
'
'改变当前进程的状态
m_State = MAIL_DOT
'
'现在我们可以开始发送邮件正文
'文本的每一行必须以vbLf结尾
'记住不是vbCrLf
'
'发送邮件主题
winsock1.SendData "Subject:" & "tt" & vbLf
Dim varLines As Variant
Dim varLine As Variant
'
'解析邮件以获得行(VB6适用)
varLines = Split("pp", vbCrLf)
'
'发送每一行邮件
For Each varLine In varLines
winsock1.SendData CStr(varLine) & vbLf
'
Debug.Print CStr(varLine)
Next
'
'向服务器发送一个小数点告诉服务器邮件发送完毕。
winsock1.SendData "." & vbCrLf
'
Debug.Print "."
'
Case MAIL_DOT
'改变当前进程的状态
m_State = MAIL_QUIT
'
'向服务器发送QUIT命令
winsock1.SendData "QUIT" & vbCrLf
Case MAIL_QUIT
'
'断开连接
winsock1.Close
'
End Select
Else
'
'如果服务器返回一个错误的代码就断开连接并提示用户
'
winsock1.Close
'
MsgBox "SMTP Error: " & strServerResponse, vbInformation, "SMTP Error"
'
End If
End Sub
smtp error:500 error :bad syntax
源码
Private Sub Command6_Click()
winsock1.Connect Trim$("smtp.163.com", 25
m_State = MAIL_CONNECT
End Sub
Dim strServerResponse As String
Dim strResponseCode As String
Dim strDataToSend As String
winsock1.GetData strServerResponse
strResponseCode = Left(strServerResponse, 3)
If strResponseCode = "250" Or strResponseCode = "220" Or strResponseCode = "354" Then
Select Case m_State
Case MAIL_CONNECT
m_State = MAIL_HELO
strDataToSend = Trim$("f19881021@163.com"
'
'获取信箱名
strDataToSend = Left$(strDataToSend, InStr(1, strDataToSend, "@" - 1)
'向服务器发送HELO命令
winsock1.SendData "HELO " & strDataToSend & vbCrLf
'
Case MAIL_HELO
'
'改变当前进程的状态
m_State = MAIL_FROM
'
'向服务器发送 MAIL FROM命令
winsock1.SendData "MAIL FROM: " & Trim$("f19881021@163.com" & vbCrLf
Case MAIL_FROM
'
'改变当前进程的状态
m_State = MAIL_RCPTTO
'
'
winsock1.SendData "RCPT TO:" & Trim$("f19881021@163.com" & vbCrLf
'
Case MAIL_RCPTTO
'
'改变当前进程的状态
m_State = MAIL_DATA
'
'向服务器发送DATA命令
winsock1.SendData "DATA" & vbCrLf
Case MAIL_DATA
'
'改变当前进程的状态
m_State = MAIL_DOT
'
'现在我们可以开始发送邮件正文
'文本的每一行必须以vbLf结尾
'记住不是vbCrLf
'
'发送邮件主题
winsock1.SendData "Subject:" & "tt" & vbLf
Dim varLines As Variant
Dim varLine As Variant
'
'解析邮件以获得行(VB6适用)
varLines = Split("pp", vbCrLf)
'
'发送每一行邮件
For Each varLine In varLines
winsock1.SendData CStr(varLine) & vbLf
'
Debug.Print CStr(varLine)
Next
'
'向服务器发送一个小数点告诉服务器邮件发送完毕。
winsock1.SendData "." & vbCrLf
'
Debug.Print "."
'
Case MAIL_DOT
'改变当前进程的状态
m_State = MAIL_QUIT
'
'向服务器发送QUIT命令
winsock1.SendData "QUIT" & vbCrLf
Case MAIL_QUIT
'
'断开连接
winsock1.Close
'
End Select
Else
'
'如果服务器返回一个错误的代码就断开连接并提示用户
'
winsock1.Close
'
MsgBox "SMTP Error: " & strServerResponse, vbInformation, "SMTP Error"
'
End If
End Sub