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 mail.myserver.com.  Is this possible?
gillwebAsked:
Who is Participating?
 
gexenCommented:
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        = _
      "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort          = 2
Const cdoSMTPServer             = _
      "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort         = _
      "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout  = _
      "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate       = _
      "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic                  = 1
Const cdoSendUserName           = _
      "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword           = _
      "http://schemas.microsoft.com/cdo/configuration/sendpassword"

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"

      .Update
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()
      .Send
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.
0
 
Sam PanwarSr. Server AdministratorCommented:
Hi,

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
Code:

Use following code for CDOSYS Email componets.
<%
Set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = "mail.yourdomain.com"
cdoConfig.fields.update
Set cdoMessage = Server.CreateObject("CDO.Message")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = test@yourdomain.com
cdoMessage.To = "test@medomain.com"
cdoMessage.cc = "test@otherdomain.com"
cdoMessage.Subject = "enquiry form CDOSYS componets"
cdoMessage.HTMLBody = "your text"
cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing
response.redirect= "http://www.yourdomain.com"
%>

-----------------------------------------------------------------------------------------------------
For CDONTS:
01. <%
02. Dim objCDOMail
03. Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
04. objCDOMail.From = "fromEmail@fromDomain.com"
05. objCDOMail.To = "toEmail@toDomain.com"
06. objCDOMail.Cc = "ccEmail@ccDomain.com"
07. objCDOMail.Bcc = "bcc@mailDomain.com"
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
0
 
dnojcdCommented:
there is an option of smart host in IIS SMTP server. there i think you can give your ISP`s SMTP server
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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?
0
 
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?
0
 
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?
0
 
Sam PanwarSr. Server AdministratorCommented:
Hi,

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

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

http://aspalliance.com/583
0
 
Sam PanwarSr. Server AdministratorCommented:
Also check the metabase setting of IIS
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.