An IIS SMTP server can be configured to silently delete or archive messages as the end point in a message route for a test lab. IIS SMTP archives messages by default for alias domains and uses performance counters to track statistics. A simple CDO script can be used to delete the messages instead of archiving them.
Setting up IIS SMTP server
Windows 2000 server, Windows 2003 server, and Windows XP Professional include a SMTP server as part of IIS. This is the same protocol engine as that used for Exchange. Once the SMTP server is installed, the server must be configured to accept mail for the domains used in the test lab.
To add a domain:
Start Internet Information Services (IIS) Manger from Administrative Tools.
Expand the SMTP Virtual Server and select the Domains container.
Right click on Domains and select "New -> Domain...".
Select "alias" domain type and add the name FQDN of the test domain.
Repeat steps 3 and 4 for each test domain to be used. If a test domain is not added, the server will refuse to accept mail for the domain. Detailed instructions for creating and deleting SMTP domains can be found in Managing SMTP Domains.
The server is now configured to archive all mail sent to the domains added above in the SMTP VSI’s drop directory (%SystemRoot%\Inetpub\MailRoot\Drop for default).
If the mail is not needed to be archived, then see the next section for automatically deleting messages using the OnArrival Sink.
Managing Message Deletion Sink
Sinks are used to change behaviors of the SMTP server. The following vbscript example marks for deletion any message that is called for, and then aborts calls to any other sink.
' just returns S_OK
Sub ISMTPOnArrival_OnArrival(ByVal iMsg, EventStatus )
Save the script as DeleteMsg.vbs on the IIS SMTP server in
%SystemDrive%\InetPub\AdminScripts. This is not a required location, but makes it easier to track.
The next step is getting the Event Management Script and saving it as smtpreg.vbs in the same location as DeleteMsg.vbs. This script will allow you to add, remove, and enumerate sinks on the IIS SMTP server.
Once this sink is in place, no messages will be dropped into the Drop directory (messages are deleted OnArrival).
Monitoring Server with Perfmon counters
Perfmon.msc can be used to monitor the performance of the IIS SMTP server using the built in counters for SMTP Server Object. Messages Received Total can be used to track the total number of messages submitted. The SMTP Server Object can also be used to track bytes and averages. The counters can be reset by stopping and starting the SMTP VSI under the IIS Manager.
Accept and Delete All Domains (Advanced)
WARNING: The following settings should only be set in a test lab. Enabling this on a production machine can possible allow remote users to use your server as an open relay. See HOW TO: Prevent Mail Relay article for more information.
If there is no need to archive messages and it is desired that the sink not be configured for a particular domain, then the server can be configured as an open relay to accept mail for all domains. The sink will then delete the message as they come in, thus preventing the messages from actually being delivered.
To configure this:
Follow the instructions under the Managing Message Deletion Sink section to add the sink.
Start the IIS Manager and right click on the SMTP VSI and select properties.
Select the Delivery tab > Advanced
Set Smart host to fake machine name. This will ensure that messages will not route to their real domains if the sink is removed.