这个winsock发邮件,报错"503 Error: send HELO/EHLO first",要怎么修改下?
另外winsock是不是会cpu开销很大?
用winsock发邮件,报错"503 Error: send HELO/EHLO first".求帮助.多谢!全部完整源码:
Dim Progress
Dim Green_Light As Boolean
Dim DATAFile As String
Private Sub Form_Load()
Progress = 0
Load LOG_FORM
LOG_FORM.Show
MAIL_FROM = "1111111111111@qq.com"
FROM = "1111111111"
RCPT_TO = "6666666666@qq.com"
MAIL_TO = "6666666666"
SMTP_HOST = "smtp.qq.com"
SUBJECT = "11111111111111111111111111111"
End Sub
Private Sub Form_Terminate()
Unload Me
Me.Hide
Unload LOG_FORM
LOG_FORM.Hide
End
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub MAIL_RESET_Click()
Winsock1.Close
SMTP_HOST = ""
FROM = ""
MAIL_FROM = ""
MAIL_TO = ""
RCPT_TO = ""
SUBJECT = ""
DATA = ""
STATUS = ""
End Sub
Private Sub SEND_MAIL_Click()
Winsock1.Close
Winsock1.Connect SMTP_HOST, "25"
Do While Winsock1.State <> sckConnected
DoEvents
STATUS.Text = "Connecting to " & SMTP_HOST & ". Please wait."
Loop
STATUS.Text = "Connected to " & SMTP_HOST & "."
LOG_FORM.LOG_TEXT.Text = LOG_FORM.LOG_TEXT.Text & "Connected to " & SMTP_HOST & "." & Chr$(13) & Chr$(10)
Do While Green_Light = False
DoEvents
STATUS.Text = "Waiting for reply..."
Loop
Winsock1.SendData "MAIL FROM: " & MAIL_FROM & Chr$(13) & Chr$(10)
LOG_FORM.LOG_TEXT.Text = LOG_FORM.LOG_TEXT.Text & "MAIL FROM: " & MAIL_FROM & Chr$(13) & Chr$(10)
Do While Progress <> 1
DoEvents
STATUS.Text = "Sending data. (1 of 3)"
Loop
Winsock1.SendData "RCPT TO: " & RCPT_TO & Chr$(13) & Chr$(10)
LOG_FORM.LOG_TEXT.Text = LOG_FORM.LOG_TEXT.Text & "RCPT TO: " & RCPT_TO & Chr$(13) & Chr$(10)
Do While Progress <> 2
DoEvents
STATUS.Text = "Sending data. (2 of 3)"
Loop
Winsock1.SendData "DATA" & Chr$(13) & Chr$(10)
LOG_FORM.LOG_TEXT.Text = LOG_FORM.LOG_TEXT.Text & "DATA" & Chr$(13) & Chr$(10)
Do While Progress <> 3
DoEvents
STATUS.Text = "Setting up body transfer..."
Loop
Winsock1.SendData "FROM: " & FROM & " <" & MAIL_FROM & ">" & Chr$(13) & Chr$(10)
Winsock1.SendData "TO: " & MAIL_TO & " <" & RCPT_TO & ">" & Chr$(13) & Chr$(10)
Winsock1.SendData "SUBJECT: " & SUBJECT & Chr$(13) & Chr$(10)
Winsock1.SendData Chr$(13) & Chr$(10)
Winsock1.SendData DATA & Chr$(13) & Chr$(10)
LOG_FORM.LOG_TEXT.Text = LOG_FORM.LOG_TEXT.Text & DATA & Chr$(13) & Chr$(10)
Winsock1.SendData Chr$(13) & Chr$(10) & "." & Chr$(13) & Chr$(10)
LOG_FORM.LOG_TEXT.Text = LOG_FORM.LOG_TEXT.Text & Chr$(13) & Chr$(10) & "." & Chr$(13) & Chr$(10)
Do While Progress <> 4
DoEvents
STATUS.Text = "Sending data. (3 of 3)"
Loop
Winsock1.SendData "QUIT" & Chr$(13) & Chr$(10)
STATUS.Text = "Done"
Winsock1.Close
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData DATAFile
Reply = Mid(DATAFile, 1, 3)
LOG_FORM.LOG_TEXT.Text = LOG_FORM.LOG_TEXT.Text & DATAFile & Chr$(13) & Chr$(10)
If Reply = 250 Or Reply = 354 Then
Progress = Progress + 1
End If
If Reply = 220 Then
Green_Light = True
End If
End Sub