Relay All ASP Email to outside SMTP?

When I send email through an ASP page through my local "intranet" it sends through the normal IIS Default SMTP server.  Is there a way to make an external SMTP server the default.  In other words I want all email through ASP to be sent through  Is this possible?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What email component are you using?  Most of them allow you to specify what mail server to send through.  If you're using CDO, you can use this code:

Const cdoSendUsingMethod        = _
Const cdoSendUsingPort          = 2
Const cdoSMTPServer             = _
Const cdoSMTPServerPort         = _
Const cdoSMTPConnectionTimeout  = _
Const cdoSMTPAuthenticate       = _
Const cdoBasic                  = 1
Const cdoSendUserName           = _
Const cdoSendPassword           = _

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
      .Item(cdoSendUsingMethod)       = cdoSendUsingPort
      .Item(cdoSMTPServer)            = "smtp_server_name"
      .Item(cdoSMTPServerPort)        = 25
      .Item(cdoSMTPConnectionTimeout) = 10
      .Item(cdoSMTPAuthenticate)      = cdoBasic
      .Item(cdoSendUserName)          = "username"
      .Item(cdoSendPassword)          = "password"

End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
      .To       = "Display Name <email_address>"
      .From     = "Display Name <email_address>"
      .Subject  = "SMTP Relay Test"
      .TextBody = "SMTP Relay Test Sent @ " & Now()
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

Alternatively, you could configure your local SMTP server as a smarthost to another mail server.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sam PanwarSr. Server AdministratorCommented:

This is possible through the ASP for it you can use the CDOSYS code CDOSYS support Window 2003 and forwindow 2000 server  CDONTS
/Use the following code in your asp page

Use following code for CDOSYS Email componets.
Set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = ""
Set cdoMessage = Server.CreateObject("CDO.Message")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From =
cdoMessage.To = "" = ""
cdoMessage.Subject = "enquiry form CDOSYS componets"
cdoMessage.HTMLBody = "your text"
Set cdoMessage = Nothing
Set cdoConfig = Nothing
response.redirect= ""

01. <%
02. Dim objCDOMail
03. Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
04. objCDOMail.From = ""
05. objCDOMail.To = ""
06. objCDOMail.Cc = ""
07. objCDOMail.Bcc = ""
08. objCDOMail.Subject = "Subject"
09. objCDOMail.BodyFormat = 0
10. objCDOMail.MailFormat = 0
11. objCDOMail.Body = "MailBody"
12. objCDOMail.Importance = 1
13. objCDOMail.Send
14. Set objCDOMail = Nothing
15. %>
Explanation According to Line
01. Open ASP tag
02. Declare a variable named objCDOMail
03. Create instance of Mailer control
04. Set Mailer control properties and collection items
05. Set Mailer control properties and collection items
06. Set Mailer control properties and collection items
07. Set Mailer control properties and collection items
08. Set Mailer control properties and collection items
09. Set Mailer control properties and collection items
10. Set Mailer control properties and collection items
11. Set Mailer control properties and collection items
12. Set Mailer control properties and collection items
13. Send Mail
14. Release resources
15. Close ASP tag

IF you get error then may be your server have not installed CDOSYS check and then try
there is an option of smart host in IIS SMTP server. there i think you can give your ISP`s SMTP server
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

gillwebAuthor Commented:
This SmartHost seems like the way to go since apparently the CDOSYS option isn't on my machine?  Can some one explain how I tell IIS to send mail through an ISP SMTP?
gillwebAuthor Commented:
gexen....i think your solution for CDO is working.  Is there a way to make this a FUNCTION to be able to import it into different pages easily?
gillwebAuthor Commented:
I keep getting IIS shutting down giving me an error stating this:

zAppName : inetinfo.exe     szAppVer : 5.1.2600.2180    
szModName : ntfsdrv.dll     szModVer : 6.0.2600.1     offset : 000032e3

Any ideas?
Sam PanwarSr. Server AdministratorCommented:

for your information cdosys is already installed on the window server 2003 if you have installed the .

This ntfs file error this may due to the permission of the IIS file in th ntfs
you have any changes in the IIS recently or permission

check the permission and event viewer for more erro discription
Sam PanwarSr. Server AdministratorCommented:
Also check the metabase setting of IIS
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.