Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies


Can SMTP be specified?



9:44 am on Feb 5, 2004 (gmt 0)

10+ Year Member


We have an ASP mail script running on our server, and all is fine with it.

However, we have been asked by our host to specify somewhere in the code which SMTP server the mail should be sent through.

I know this can be done with ASPmail and ASPemail. Can it be done with CDONTS?

Obviously, if i have to, i will just change the code, but hoped I might be able to add something to my CDONTS before re-writing to ASPemail.

The code i have used is like this:

Set mail = Server.CreateObject("CDONTS.NewMail")
mail.From = "info@mydomain.com"
mail.To = "email pulled from Database"
mail.Subject = "My email subject"
mail.Body = "messaage goes here"




8:44 pm on Feb 5, 2004 (gmt 0)

10+ Year Member

Not with classic ASP...have to use the IIS SMTP on that machine as far as I know. I believe that with ASP.Net you can use the built in mail namespaces that ride CDONTS to specify another server other than the default though.


7:36 pm on Feb 6, 2004 (gmt 0)

10+ Year Member

If you are running on IIS5 (W2K) or newer you can specify mail using the improved CDOSYS object rather than the old CDONTS.

CDOSYS is similar to CDONTS but allows you to specify the CDO.Configuration object which allows you to send to another SMTP server.

Below is some example code:

'-- Dimension and Create Objects --
Dim objMessage, objConfig
Set objMessage = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")

'-- Create Configuration --
With objConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.example.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
End With

'-- Send Email --
With objMessage
.Configuration = objConfig
.To = "user_receive@example.com"
.From = "user_send@example.com"
.Subject = "Test Email"
.HTMLBody = "Test Email Body"
End With

'-- Destroy Objects --
Set objMessage = Nothing
Set objConfig = Nothing

It is a rewritten version of [developersdex.com ] which is an ASP.NET version.



Featured Threads

Hot Threads This Week

Hot Threads This Month