Why does CDO.Message give me 8004020F errors?

Classic ASP test code:

NAME=”CDO for Windows 2000 Library”
Set cdoConfig = CreateObject(“CDO.Configuration”)
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = “localhost”
End With
Set cdoMessage = CreateObject(“CDO.Message”)
With cdoMessage
Set .Configuration = cdoConfig
.From = “from@email”
.To = “to@email”
.Subject = “Test CDO Message..”
.TextBody = “This is only a test (CDO.message)”
End With
if err <> 0 then
response.write err.number & “  -  ” & err.description
end if
Set cdoMessage = Nothing
Set cdoConfig = Nothing

This error message indicates that the email relay was rejected by the SMTP server because this user mailbox doesn’t below on this server. This server isn’t configured to relay emails to an outside server.

Using TELNET you can verify this

C:>telnet localhost 25
220 myserver.domain.local Microsoft ESMTP MAIL Service ready at Sun, 31
Oct 2010 13:34:11 +0400
helo myserver
250 myserver.domain.local Hello [::1]
mail from: admin@yahoo.com
250 2.1.0 Sender OK
rcpt to: any@msn.com
550 5.7.1 Unable to relay

You can see above that the user any@msn.com was rejected.


  • Replace the recipient email with a hosted email by the server or
  • create a web user on this server and forward it to an external email or
  • configure the server as a relay server (not a good idea).

This also applies to Windows Server 2008 with Exchange 2010

By George Lopez-Henriquez / www.inetnj.com

Comments are closed.