问题
CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/check.asp, line 25
please help to solve this problem
check this code
<%@ Language=VBScript %>
<html>
<head>
</head>
<body>
<%
dim to_field, message
to_field = Request.Form("to_field")
message = Request.Form("message")
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.example.com"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "admin@example.com" ' the address you want the email to be from
objCDOSYSMail.TO = "anuradha@gmail.com" 'the address the mail is to be sent to
objCDOSYSMail.Subject = "Subject goes here"
objCDOSYSMail.HTMLBody = "fffffffffff"
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
%>
<p>Mail sent successfully to address <%=to_field%>!</p>
</body>
</html>
回答1:
You need to add your user name and password before sending. This is because you used a value of 2 in the sendusing's field. This means you're using authentication.
'Your UserID on the SMTP server'
objCDOSYSCon.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourusername"
'Your password on the SMTP server'
objCDOSYSCon.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
回答2:
You are missing 4 important config parameters for this code to work. Replace your code with this and it will work for sure. (Personally Tested)
They are the authentication , SSL , username and password parameters.
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youremail@email.com"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "youpasswordforyouremail"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
来源:https://stackoverflow.com/questions/4333068/asp-cdo-message-1-error-80040213-the-transport-failed-to-connect-to-the-server