Classic ASP, Sending E-mail error '8004020f

2019-08-12 18:49发布

问题:

I am getting error, when I send a mail

error '8004020f'
/sis/mail.asp, line 168

Here my code.

Set cdoConfig = Server.CreateObject( "CDO.Configuration")

cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="mail.dartconsulting.info"
cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 
cdoConfig.Fields.Update

Set cdoMessage = Server.CreateObject ("CDO.Message")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = "darteam28@gmail.com"

cdoMessage.To=email
cdoMessage.Subject = "Your  Password"
cdoMessage.HtmlBody = "<table><tr><td></td></tr>"&_
                "<tr><td colspan=2>Please find below your password</td></tr>"&_
                "<tr><td>Password :&nbsp;&nbsp;"&password&"</td></tr>"&_
                "<tr><td>UserName :&nbsp;&nbsp;"&uid&"</td></tr>"&_
                "<tr><td>EmailID :&nbsp;&nbsp;"&email&"</td></tr>"&_
                "<tr><td colspan=2>Please login and confirm/change your emailid</td></tr><table>"

cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing

回答1:

There isn't enough information in your post to solve the problem, as Vogel612 said. However, by far the most likely cause is that the server mail.dartconsulting.info requires authentication, while you are trying to send without authentication.

I have connected to this server from my local computer and it gave me 550 Authentication is required for relay, so even if you're located on the same server there's a high likelihood that you also need to be authenticated.

Please refer to this website: http://www.powerasp.net/content/new/sending_email_cdosys.asp (or do a Google search) on how to send email with CDO with authentication.



回答2:

This work for me: http://www.powerasp.net/content/new/sending_email_cdosys.asp

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 

'This section provides the configuration information for the remote SMTP server.

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="remoteserver"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60


ObjSendMail.Configuration.Fields.Update

'End remote SMTP server configuration section==

ObjSendMail.To = "test@test.com"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "someone@someone.net"

' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"

ObjSendMail.Send

Set ObjSendMail = Nothing 


回答3:

Make send using as 1 instead of 2

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1



回答4:

The system will produce an error '8004020f' on an invalid recipient email address.

In my case, the issue was related to an invalid email address with a space before the @ sign.



标签: asp-classic