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.
- 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.
- Expand ServerName (local
computer), expand Default SMTP Virtual Server, and
then click Domains.
- Right-click Domains, point to
New, and then click Domain.
- Click Alias, click Next,
type the fully qualified domain name (FQDN) of your test domain in the
Name box, and then click Finish.
- 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
- 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>
- 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. - 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:
- Copy the code that appears on this Web site to a file
that is named Smtpreg.vbs.
- 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:
- Start a command prompt, and then change to the
%SYSTEMDRIVE%\InetPub\AdminScripts folder.
- 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. - 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:
- Start a command prompt, and then change to the
%SYSTEMDRIVE%\InetPub\AdminScripts folder.
- 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:
- Follow the instructions in the "Configure a message removal event sink" section of this
article to configure the DeleteMsg.vbs event sink.
- Start the Internet Information Services (IIS) Manager
tool.
- Expand ServerName (local
computer), right-click the SMTP virtual server where you configured
the event sink, and then click Properties.
- Click the Delivery tab, and then click
Advanced.
- 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.
- Click OK, and then click the
Access tab.
- Click Relay, click All except the
list below, and then click OK two times.