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.
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:
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.
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.
<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>
More information on implementing sinks for SMTP can be found in Implementing SMTP Event Sinks for CDO.
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.
The final step is registering the sinks. More detailed information can be found in Managing Event Bindings.
To add the sink, do the following:
To remove the sink, do the following:
Once this sink is in place, no messages will be dropped into the Drop directory (messages are deleted OnArrival).
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.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.