emailasp-classiccdo.message

sending email using CDO.Message - fails when sending to external address


I'm trying to use CDO.Message to send emails from my web server. Everything works OK when sending to an internal email address, but fails when sending to an external one.

error '8004020f'
sendmail.asp, line 46

Line 46 is myMail.Send

I've tried it with authentication (currently commented out), tried it without, and still get the same error. Tried the various suggestions I've found on here but nothing worked so far.

I'm assuming it's an authentication issue, but it failed even when I used authentication.

The "from" address is valid live account on the mail server. And the user/pass settings used were for the "from" address.

Any pointers to pinpoint this?

Set myMail=CreateObject("CDO.Message")
myMail.Subject="subject_goes_here"
myMail.From="from_email_address"
myMail.To="to_email_address"
myMail.TextBody="body goes here"

myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="mail_server_address"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
'myMail.Configuration.Fields.Item _
'("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
'myMail.Configuration.Fields.Item _
'("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"


myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing

Web server is IIS6 on Windows Server 2003 R2. Mail server is Exchange.

update - i'm now trying to use gmail to send the email, and getting a different error.

CDO.Message.1 error '80040213'
The transport failed to connect to the server.
sendemail.asp, line 48

and the code i'm using is

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.gmail.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=465
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "gmailusername"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

Solution

  • well i eventually got this resolved. but we ended up using a different mail provider, which allowed authenticated SMTP relay.