?
Solved

Relay All ASP Email to outside SMTP?

Posted on 2006-04-12
8
Medium Priority
?
490 Views
Last Modified: 2010-08-05
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?
0
Comment
Question by:gillweb
8 Comments
 
LVL 1

Accepted Solution

by:
gexen earned 200 total points
ID: 16442249
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
 
LVL 18

Expert Comment

by:Sam Panwar
ID: 16442263
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
 
LVL 10

Expert Comment

by:dnojcd
ID: 16442618
there is an option of smart host in IIS SMTP server. there i think you can give your ISP`s SMTP server
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:gillweb
ID: 16444956
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
 

Author Comment

by:gillweb
ID: 16445178
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
 

Author Comment

by:gillweb
ID: 16445202
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
 
LVL 18

Expert Comment

by:Sam Panwar
ID: 16450729
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
 
LVL 18

Expert Comment

by:Sam Panwar
ID: 16450743
Also check the metabase setting of IIS
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question