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

Solution 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: 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.

Solution 2:

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.