Microsoft KB Archive/837851

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

Article ID: 837851

Article Last Modified on 11/30/2007

-

APPLIES TO


 * Microsoft Exchange Server 2003 Enterprise Edition
 * Microsoft Exchange Server 2003 Standard Edition
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows XP Professional
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server

-



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



IN THIS TASK

 * INTRODUCTION
 * Configure the SMTP server in Internet Information Services
 * Configure a message removal event sink
 * Configure performance counters
 * Configure the event sink to remove messages from any domain
 * REFERENCES



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.

back to the top

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.  Install the SMTP Service by using the Add or Remove Programs tool in Control Panel. To do this, follow these steps:  Click Start, point to All Programs, and then click Control Panel. Click Add or Remove Programs. 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. Click Next, insert your Windows CD if you are prompted, and then click Finish when the Windows Components Wizard has completed successfully.  Start the Internet Information Services (IIS) Manager tool.</li> Expand  (local computer), expand Default SMTP Virtual Server, and then click Domains.</li> Right-click Domains, point to New, and then click Domain.</li> Click Alias, click Next, type the fully qualified domain name (FQDN) of your test domain in the Name box, and then click Finish.</li> 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 &quot;REFERENCES&quot; section of this article.</li></ol>

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.

back to the top

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 &quot;REFERENCES&quot; 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
  Copy and then paste the following VBScript code to a file that is named DeleteMsg.vbs: <SCRIPT LANGUAGE=&quot;VBScript&quot;>

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(&quot;http://schemas.microsoft.com/cdo/smtpenvelope/messagestatus&quot;) = cdoStatusAbortDelivery

Flds.Update

EventStatus = cdoSkipRemainingSinks

iMsg.DataSource.Save

End Sub

</SCRIPT> </li> 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.</li> 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:  Visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/ms528023.aspx

</li> Copy the code that appears on this Web site to a file that is named Smtpreg.vbs.</li></ol> </li> Register the event sink. For additional information about how to register or un-register event sinks, see the &quot;REFERENCES&quot; section of this article. To register the event sink, follow these steps:  Start a command prompt, and then change to the %SYSTEMDRIVE%\InetPub\AdminScripts folder.</li> Type the following command, and then press ENTER:

cscript smtpreg.vbs /add  OnArrival DeleteMsg CDO.SS_SMTPOnArrivalSink &quot;mail from=*&quot;

Note Replace  with the SMTP virtual server instance number. For example, replace  with 1.</li> <li>Type the following command, and then press ENTER:

cscript smtpreg.vbs /setprop  OnArrival DeleteMsg Sink ScriptName &quot; :\Inetpub\AdminScripts\DeleteMsg.vbs&quot;

Note Replace  with the letter of the drive where the DeleteMsg.vbs file is located.</li></ol>

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: <ol style="list-style-type: lower-alpha;"> <li>Start a command prompt, and then change to the %SYSTEMDRIVE%\InetPub\AdminScripts folder.</li> <li>Type the following command, and then press ENTER:

cscript smtpreg.vbs /remove  OnArrival DeleteMsg

Note Replace  with the SMTP virtual server instance number. For example, replace  with 1.</li></ol> </li></ol>

back to the top

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.

back to the top

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 &quot;REFERENCES&quot; 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 &quot;Configure a message removal event sink&quot; section of this article to configure the DeleteMsg.vbs event sink.
 * 2) Start the Internet Information Services (IIS) Manager tool.
 * 3) Expand   (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

<div class="references_section">