Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDOSYS - Can't email outside of network

Status
Not open for further replies.

nidifice

Programmer
Oct 9, 2003
47
US
I can get this code below to email anywhere within the company, but not outside the network.

I've tried the values 0 (anonymous), 1 (basic), and 2 (NTLM) for the 'smtpauthenticate' variable. When using 0 I receive error:
The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for dustinbrooks71@hotmail.com

Using the values 1 or 2 I get:
The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available



Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

objCDOSYSCon.Fields("ht*p://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailexch.rghp.com"
objCDOSYSCon.Fields("ht*p://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("ht*p://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("ht*p://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields("ht*p://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objCDOSYSCon.Fields("ht*p://schemas.microsoft.com/cdo/configuration/sendusername") = "mydomain\myusername"
objCDOSYSCon.Fields("ht*p://schemas.microsoft.com/cdo/configuration/sendpassword") = "******"

objCDOSYSCon.Fields.Update

Set objCDOSYSMail.Configuration = objCDOSYSCon

objCDOSYSMail.From = "gnet@gordmans.com"
objCDOSYSMail.To = "dustinbrooks71@hotmail.com"
objCDOSYSMail.Subject = "Subject goes here"
objCDOSYSMail.HTMLBody = "test here"

objCDOSYSMail.Send


I'm not sure what else to try.
 
Hey Dustinbrookes,

Itried the same thing few days back CDOSYS. It worked for me to send message out of network too. I am pesting code I used. I hope it works for you too.

<%
'Declare variables
Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody
Dim sHTMLBody

sTo = Request(&quot;sTo&quot;)
sFrom = Request(&quot;sFrom&quot;)
sSubject = Request(&quot;sSubject&quot;)
sTextBody = Request(&quot;sTextBody&quot;)
sHTMLBody = Request(&quot;sHTMLBody&quot;)

'Only run this if it's not the first time
If Request.Form(&quot;Submit&quot;) <> &quot;&quot; Then

Dim objConfiguration
dim objFields

Const cdoSendUsingMethod = &quot; Const cdoSendUsingPort = 2
Const cdoSMTPServer = &quot; Const cdoSMTPServerPort = &quot; Const cdoSMTPConnectionTimeout = &quot; Const cdoSMTPAuthenticate = &quot; Const cdoBasic = 1
Const cdoSendUserName = &quot; Const cdoSendPassword = &quot;
Set objConfiguration = Server.CreateObject(&quot;CDO.Configuration&quot;)

Set objFields = objConfiguration.Fields

With objFields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPServer) = &quot;localhost&quot;
.Item(cdoSMTPConnectionTimeout) = 10
.Update
End With


Dim objMail
'Create the mail object
Set objMail = Server.CreateObject(&quot;CDO.Message&quot;)

set objMail.Configuration = objConfiguration
'Set key properties
objMail.From = sFrom
objMail.To = sTo
objMail.Subject= sSubject
objMail.TextBody = sTextBody
objMail.HTMLBody = sHTMLBody

'Send the email
objMail.Send

'Set sMsg which will be used to inform on the screen in response.write
sMsg = &quot;Your message was sent to: &quot; & sTo

'Clean object
Set objMail = Nothing

End If
%>

Or may be you have to check SMTP configuration on your server. I set SMTP configuration using infoprovided at following link

I hope it works for you.

All the Best!!!





Yogesh
 
any Firewalls installed possibly preventing it????

_____________________________________________________________________
onpnt2.gif
[sub]
Hakuna matata!!
[/sub]
 
I figured out this one on my own.

When entering a username and password, it needs to be the username and password for the smtp server; this may seem obvious, but I was using my domain username and password.
So, if your windows login is different from your email, use an email validated login for cdosys.
 
What is the bare minimum I could use inthe above code to make a function to send simple mail?

 
I'm not sure if this is the ABSOLUTE minimum, but it is pretty darn close.


Dim objCDOSYSCon

Set objCDOSYSMail = Server.CreateObject(&quot;CDO.Message&quot;)
Set objCDOSYSCon = Server.CreateObject (&quot;CDO.Configuration&quot;)

objCDOSYSCon.Fields(&quot; = &quot;mailserver.com&quot;
objCDOSYSCon.Fields(&quot; = 25
objCDOSYSCon.Fields(&quot; = 2

objCDOSYSCon.Fields.Update

Set objCDOSYSMail.Configuration = objCDOSYSCon

objCDOSYSMail.From = &quot;webmaster@zib.com&quot;
objCDOSYSMail.To = &quot;dustinbrooks@cox.com&quot;
objCDOSYSMail.Subject = &quot;TEST2&quot;
objCDOSYSMail.HTMLBody = &quot;TEST&quot;

objCDOSYSMail.Send
 
The forums do that. I put **** in place of the http's

objCDOSYSCon.Fields(&quot;****://schemas.microsoft.com/cdo/configuration/smtpserver&quot;) = &quot;mailexch.rghp.com&quot;
objCDOSYSCon.Fields(&quot;****://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;) = 25
objCDOSYSCon.Fields(&quot;****://schemas.microsoft.com/cdo/configuration/sendusing&quot;) = 2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top