Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to configure an Internet Information Services SMTP virtual server to archive or to remove messages in an Exchange Server 2003 test environment


View products that this article applies to.

Summary

To configure a Microsoft Internet Information Services (IIS) Simple Mail Transfer Protocol (SMTP) server as the end-point of a message route in a test environment, you must configure the following settings on your computer that is running Microsoft Windows Server 2003, Microsoft Windows XP Professional, or Microsoft Windows 2000 Server:
  • Install the SMTP Service
  • Configure the SMTP virtual server to accept e-mail messages for one or more domains
  • Create and then register an event sink to delete the messages from the SMTP virtual server

↑ Back to the top


Introduction

This article describes how to configure a Microsoft IIS SMTP server as the end-point of a message route in a test environment. You can use this SMTP server to archive or to remove e-mail messages in your test environment or to track message statistics.

Configure the SMTP server in Internet Information Services

Microsoft Windows Server 2003, Microsoft Windows XP Professional, and Microsoft Windows 2000 Server include a SMTP server as part of Microsoft Internet Information Services. This SMTP server is the same protocol engine that Microsoft Exchange Server uses. You can install and configure the SMTP server to accept mail for the domains that you use in your test environment. To do this, follow these steps:

Note Because there are several versions of Microsoft Windows, the following steps may be different on your computer. If they are, see your product documentation to complete these steps.
  1. Install the SMTP Service by using the Add or Remove Programs tool in Control Panel. To do this, follow these steps:
    1. Click Start, point to All Programs, and then click Control Panel.
    2. Click Add or Remove Programs.
    3. Click Add/Remove Windows Components, click Application Server, click Details, click Internet Information Services (IIS), click Details, click to select the SMTP Service check box, and then click OK two times.
    4. Click Next, insert your Windows CD if you are prompted, and then click Finish when the Windows Components Wizard has completed successfully.
  2. Start the Internet Information Services (IIS) Manager tool.
  3. Expand ServerName (local computer), expand Default SMTP Virtual Server, and then click Domains.
  4. Right-click Domains, point to New, and then click Domain.
  5. Click Alias, click Next, type the fully qualified domain name (FQDN) of your test domain in the Name box, and then click Finish.
  6. Repeat steps 4 and 5 to add each of your test domains. If you do not add a domain, the SMTP virtual server refuses to accept messages for that domain. For additional information about how to create or to remove SMTP domains, see the "REFERENCES" section of this article.
The SMTP virtual server is now configured to archive all e-mail messages that are sent to the domains that you added. The SMTP virtual server archives these messages in the Drop folder. By default, the Drop folder is located in the %SYSTEMDRIVE%\Inetpub\MailRoot\Drop folder.

Configure a message removal event sink

If you do not want to archive e-mail messages in the Drop folder, create an event sink to automatically delete the messages that are sent to the Drop folder. Event sinks are programs that are used to modify the behavior of the SMTP virtual server. For additional information about how to create an event sink, see the "REFERENCES" section of this article. The following example contains an event sink that marks for deletion any message that is called and then aborts calls to any other event sinks:

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Example

  1. Copy and then paste the following VBScript code to a file that is named DeleteMsg.vbs:
    <SCRIPT LANGUAGE="VBScript">
    
    Sub IEventIsCacheable_IsCacheable
    
      ' just returns S_OK
    
    End Sub
    
     
    
    Sub ISMTPOnArrival_OnArrival(ByVal iMsg, EventStatus )
    
      On Error Resume Next
    
     
    
      ' CDO constants
    
      Const cdoSkipRemainingSinks = 1
    
      Const cdoStatusAbortDelivery = 2
    
     
    
      Set Flds = iMsg.EnvelopeFields
    
      Flds("http://schemas.microsoft.com/cdo/smtpenvelope/messagestatus") = cdoStatusAbortDelivery
    
      Flds.Update
    
      EventStatus = cdoSkipRemainingSinks
    
      iMsg.DataSource.Save
    
    End Sub
    
    </SCRIPT>
    
    
  2. On the computer where you configured the IIS SMTP server, save the DeleteMsg.vbs file in the following folder:
    %SYSTEMDRIVE%\InetPub\AdminScripts
    Note You do not have to store this file in the AdminScripts folder. However, you may locate your script files more easily if they are stored in this folder.
  3. Obtain the Smtpreg.vbs Event Management Script, and then store it in the same folder where you saved the DeleteMsg.vbs file. You can use the Smtpreg.vbs script to add, remove, and enumerate event sinks on the IIS SMTP virtual server. To obtain this script, follow these steps:
    1. Visit the following Microsoft Developer Network (MSDN) Web site:
    2. Copy the code that appears on this Web site to a file that is named Smtpreg.vbs.
  4. Register the event sink. For additional information about how to register or un-register event sinks, see the "REFERENCES" section of this article. To register the event sink, follow these steps:
    1. Start a command prompt, and then change to the %SYSTEMDRIVE%\InetPub\AdminScripts folder.
    2. Type the following command, and then press ENTER:
      cscript smtpreg.vbs /add virtualServerInstance OnArrival DeleteMsg CDO.SS_SMTPOnArrivalSink "mail from=*"
      Note Replace virtualServerInstance with the SMTP virtual server instance number. For example, replace virtualServerInstance with 1.
    3. Type the following command, and then press ENTER:
      cscript smtpreg.vbs /setprop virtualServerInstance OnArrival DeleteMsg Sink ScriptName "drive:\Inetpub\AdminScripts\DeleteMsg.vbs"
      Note Replace drive with the letter of the drive where the DeleteMsg.vbs file is located.
    After you register this event sink, no messages are placed in the Drop folder. Instead all messages are deleted at the OnArrival event.

    To un-register the event sink, follow these steps:
    1. Start a command prompt, and then change to the %SYSTEMDRIVE%\InetPub\AdminScripts folder.
    2. Type the following command, and then press ENTER:
      cscript smtpreg.vbs /remove virtualServerInstance OnArrival DeleteMsg
      Note Replace virtualServerInstance with the SMTP virtual server instance number. For example, replace virtualServerInstance with 1.

Configure performance counters

You can use the Performance Monitor tool (Perfmon.msc) to monitor the performance of the IIS SMTP server. To do this, use the built-in counters for the SMTP Server performance object. Use the Messages Received Total performance counter to track the total number of messages that have been submitted to the SMTP virtual server. You can also use the SMTP Server performance object to track bytes and averages. To reset these counters, stop and then restart the SMTP virtual server instance by using the Internet Information Services (IIS) Manager tool.

Configure the event sink to remove messages from any domain

Warning This is an advanced configuration setting that you must restrict to a test environment. If you enable this configuration setting on a production computer, remote users may be able to use the SMTP server as an open relay. For additional information about how to help prevent mail relaying on your SMTP virtual server, see the "REFERENCES" section of this article.

If you do not want to archive e-mail messages, and if you do not want to configure the DeleteMsg.vbs event sink for a particular domain, you can configure the SMTP server as an open relay to accept mail for all domains. The event sink will then delete the messages as they arrive, preventing those messages from being delivered to their destination. To do this, follow these steps:
  1. Follow the instructions in the "Configure a message removal event sink" section of this article to configure the DeleteMsg.vbs event sink.
  2. Start the Internet Information Services (IIS) Manager tool.
  3. Expand ServerName (local computer), right-click the SMTP virtual server where you configured the event sink, and then click Properties.
  4. Click the Delivery tab, and then click Advanced.
  5. In the Smart host box, type a bogus computer name. This action is to help make sure that e-mail messages will not be routed to their destination if the event sink is removed.
  6. Click OK, and then click the Access tab.
  7. Click Relay, click All except the list below, and then click OK two times.

↑ Back to the top


References

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
303708 HOW TO: Create or delete a Microsoft SMTP service domain in Windows 2000
For more information about how to create event sinks, visit the following MSDN Web site:For more information about how to register or to un-register SMTP event sinks, visit the following MSDN Web site: For additional information about how to help prevent e-mail relaying, click the following article number to view the article in the Microsoft Knowledge Base:
324281 HOW TO: Prevent mail relay in the IIS SMTP virtual server in Windows Server 2003

↑ Back to the top


Keywords: KB837851, kbhowtomaster, kbinfo

↑ Back to the top

Article Info
Article ID : 837851
Revision : 10
Created on : 11/30/2007
Published on : 11/30/2007
Exists online : False
Views : 539