sudhagar
sudhagar

Reputation: 21

Classic ASP, Sending E-mail error '8004020f'

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 = "[email protected]"

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

Upvotes: 1

Views: 27546

Answers (5)

asp_mmmm
asp_mmmm

Reputation: 1

For me, this issue happened when we started sending bulk emails from the server. I fixed it by trippeling the smtpconnectiontimeout, from 60 to 180.

I do not know if this is a good practice though, would appreciate feedback.

Upvotes: 0

Ynhockey
Ynhockey

Reputation: 3932

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: https://web.archive.org/web/20190905195123/http://www.powerasp.net/content/new/sending_email_cdosys.asp (or do a web search) on how to send email with CDO with authentication.

Upvotes: 4

VGorbach
VGorbach

Reputation: 41

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.

Upvotes: 4

Solomon Raja
Solomon Raja

Reputation: 1790

Make send using as 1 instead of 2

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

Upvotes: 0

Hernaldo Gonzalez
Hernaldo Gonzalez

Reputation: 2046

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 = "[email protected]"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "[email protected]"

' 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 

Upvotes: 0

Related Questions