'我用winsock发邮件
'代码:---------------------------------------------------
Option Explicit
Private timer As Long
Private data As Boolean
Private inder As Boolean
Dim inData As StringPrivate Sub Command1_Click()
smtp.LocalPort = 0 '设置本地使用的端口
smtp.Protocol = sckTCPProtocol '设置Winsock控件使用的协议,TCP或UDP。
smtp.RemoteHost = "smtp.163.com" '设置发送Email的服务器
smtp.RemotePort = 25 '设置要连接的远程端口号
smtp.Connect
End SubPrivate Sub smtp_Connect()
While Not inder 'Wait for reply If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
Dim reply As String
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 220 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
Exit Sub
End If
smtp.SendData "HELO smtp.163.com" + vbCrLf
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 250 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
'''''''''''''''''''''''''''''''''''''''''''''
smtp.SendData "noop" + vbCrLf
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 250 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
''''''''''''''''''''''''''''''''''''''''''''
smtp.SendData "MAIL FROM:<[email protected]>" + vbCrLf
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 250 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
smtp.SendData "RCPT TO:<[email protected]>" + vbCrLf
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 250 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
smtp.SendData ("DATA" + vbCrLf)
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 354 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
End SubPrivate Sub Smtp_DataArrival(ByVal bytesTotal As Long)
Dim data As String
smtp.GetData data, vbString
inData = inData + data
'''''''''''''''''''''''''''''''''''''''''''''
If Len(inData) <> 0 Then
inder = True
End If
End Sub
在mail from命令以后有503的错误,提示为 you are not authorized to send to mail as <mail from:<[email protected]>>
各位高手,请问这是怎么会事啊?是不是需要服务器的认证? 如何取得认证呢?
无论晴天也好,雨天也好,我希望和你一起度过~~~~风笛
'代码:---------------------------------------------------
Option Explicit
Private timer As Long
Private data As Boolean
Private inder As Boolean
Dim inData As StringPrivate Sub Command1_Click()
smtp.LocalPort = 0 '设置本地使用的端口
smtp.Protocol = sckTCPProtocol '设置Winsock控件使用的协议,TCP或UDP。
smtp.RemoteHost = "smtp.163.com" '设置发送Email的服务器
smtp.RemotePort = 25 '设置要连接的远程端口号
smtp.Connect
End SubPrivate Sub smtp_Connect()
While Not inder 'Wait for reply If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
Dim reply As String
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 220 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
Exit Sub
End If
smtp.SendData "HELO smtp.163.com" + vbCrLf
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 250 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
'''''''''''''''''''''''''''''''''''''''''''''
smtp.SendData "noop" + vbCrLf
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 250 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
''''''''''''''''''''''''''''''''''''''''''''
smtp.SendData "MAIL FROM:<[email protected]>" + vbCrLf
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 250 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
smtp.SendData "RCPT TO:<[email protected]>" + vbCrLf
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 250 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
smtp.SendData ("DATA" + vbCrLf)
While Not inder 'Wait for reply
If smtp.State = sckClosed Then Exit Sub
DoEvents
Wend
inder = False
reply = Val(Left$(inData, 3))
inData = ""
If Not reply = 354 Then 'Error occured
MsgBox "Server returned the following error:" + vbCrLf + reply
End If
End SubPrivate Sub Smtp_DataArrival(ByVal bytesTotal As Long)
Dim data As String
smtp.GetData data, vbString
inData = inData + data
'''''''''''''''''''''''''''''''''''''''''''''
If Len(inData) <> 0 Then
inder = True
End If
End Sub
在mail from命令以后有503的错误,提示为 you are not authorized to send to mail as <mail from:<[email protected]>>
各位高手,请问这是怎么会事啊?是不是需要服务器的认证? 如何取得认证呢?
无论晴天也好,雨天也好,我希望和你一起度过~~~~风笛
S:334 VXNlcm5hbWU6
C:邮箱账号(Base64)
S:334 UGFzc3dvcmQ6
C:密码(Base64)
S:235 验证成功
无论晴天也好,雨天也好,我希望和你一起度过~~~~风笛
无论晴天也好,雨天也好,我希望和你一起度过~~~~风笛
smtp.SendData sfullmsg
这时,服务器返回 550 your message was blocked.... 请问这是为什么啊? 无论晴天也好,雨天也好,我希望和你一起度过~~~~风笛