If you have more offsite Exchange 2007 installations and dont want
to route all mail traffic to the MailScanner box itself to save
bandwidth, this is the perfect solution.
Please contact me if there are any missing options in the implementation.
Index
- How to install the MailScannerWatermark plugin for Microsoft Exchange 2007
- How to uninstall a TransportAgent for Microsoft Exchange 2007
- Conclusion
- Files
How to install the MailScannerWatermark plugin for Microsoft Exchange 2007
File are placed in the bottom.
1st step
Extract the content of the zip archive. The content should look something like below.
Filestructure
- MailScannerWatermark
- AgentProject ( source code )
- MS Files
- Microsoft.Exchange.Data.Common.dll
- Microsoft.Exchange.Data.Transport.dll
- Files
- Create.Event.Source.ps1
- MailScannerWatermark.dll
- Settings.reg
Copy "MailScannerWatermark.dll" from the "Files" directory to a folder on the Microsoft Exchange 2007 server. I have used "C:\IfYouDo.Net\" and placed the file there. You may use whatever directory you want.
2nd step
Install the plugin with the following command in the Power Shell:
[PS] C:\>install-transportagent
cmdlet install-transportagent at command pipeline position 1
Supply values for the following parameters:
Name: MailScannerWatermark
TransportAgentFactory: IfYouDo.Net.MailScannerWatermarkFactory
AssemblyPath: C:\IfYouDo.Net\MailScannerWatermark.dll
Identity Enabled Priority
-------- ------- --------
MailScannerWatermark False 10
WARNING: Please exit Powershell to complete the installation.
WARNING: The following service restart is required for the change(s) to take
effect : MSExchangeTransport
Notes:
- The AssemblyPath must to changed acordingly to the FolderPath used in step 1.
- Make sure the permissions are right on the assembly file else it will complain about the Path are incorrect.
3rd step
Enable the plugin in Power Shell with:
[PS] C:\>Enable-TransportAgent MailScannerWatermark
4th step
In the folder used above, there should be a file named "settings.reg", double click it to register the values to the register database and then edit the values or do it manualy before with notepad or similar program:
Change the values to suit your needs:
| Debug |
True/False |
| HeaderName |
HeaderName used in the MailScanner installation, excluding the ":"
(colon). The HeaderName will be trimmed for any ":" in the end, just to
make sure no one just copies the HeaderName from the MailScanner
settings. |
| Secret |
The secret used in the Mailscanner installation, if MultipleDomains are "False" |
| Expiry |
How many days the Watermark is valid. |
| MultipleDomains |
True/False. If "True", it will look for the domain in the regdb, and
use that secretkey if found. If the domain is not found, and "Secret" is in the regdb it will use that secretkey else it will just skip
that domain. If "False" it will use "Secret" value as key for all
doamins. |
| domainname.tld |
secretkey
|
Example 1 - Same secret for all domains.

Example 2 - domain1.com and domain2.com have diff keys but "Secret" are used for all others
Remove the "Secret" key from the regdb, if you dont want other domains than domain1.com and domain2.com to get tagged with a Watermark.

5th step
Run the following command in the Power Shell to restart the Microsoft Exchange Transport.
[PS] C:\>Restart-service MSExchangeTransport
6th step
Run the "Create.Event.Source.ps1" from the Files folder, this will create an EvenLog Source "MailScannerWatermark" in the Application log.
7th step
First ... use debug ... there will be some info about the time found, msgid, etc. so we know its right.
Then send an email to a valid recipient, to see that the watermark is actually there.
Then send an email to an invalid recipient, that you know will send a message back to you, and make sure its get a NDR.
Then telnet to a public ISP SMTP server, and make a fake email, that we know will not get a valid watermark.
All text below with a "C:" before the line are client commands, and needs to be written by you, the others are server responses.
Make a "telnet" connected to a smtp. Like the below if you are running Windows. The prompt may differ a little.
cmd> telnet some.smtp.tld 25
S: 220 smtp.example.com ESMTP Postfix
C: HELO relay.example.org
S: 250 Hello relay.example.org, I am glad to meet you
C: MAIL FROM:<bob@example.org>
S: 250 Ok
C: RCPT TO:<alice@example.com>
S: 250 Ok
C: RCPT TO:<theboss@example.com>
S: 250 Ok
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C: Subject: Test message
C: Hello Alice.
C: This is a test message
C: Your friend,
C: Mikael Syska
C: .
S: 250 Ok: queued as 12345
C: QUIT
S: 221 Bye
The above example should be with a valid from address and an invalid recipient address, so we will get a NDR, but this time it should be taken by the MailScanner server, since it does not contain a valid Watermark.
How to uninstall a TransportAgent for Microsoft Exchange 2007
1st Step
Will give you a list of all installed transportagents
[
PS] C:\>transportagent
Identity Enabled Priority
-------- ------- --------
Transport Rule Agent True 1
Journaling Agent True 2
Connection Filtering Agent True 4
Content Filter Agent True 5
Sender Id Agent True 6
Sender Filter Agent True 7
Recipient Filter Agent True 8
Protocol Analysis Agent True 9
MailScannerWatermark True 10
2nd Step
From the list above, I have choosen to uninstall the "MailScannerWatermark" plugin.
[PS] C:\>uninstall-transportagent MailScannerWatermark
Confirm
Are you sure you want to perform this action?
Uninstalling Transport agent "MailScannerWatermark". A service restart is
required for the change to take effect.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):
Type "Y" to confirm that you want to uninstall it
3rd Step
Run the following command in the Power Shell to restart the Microsoft Exchange Transport.
[PS] C:\>Restart-service MSExchangeTransport
Now the plugin is uninstalled from the system.
Conclusion
This have been very fun to play with Microsoft new Transport-Agents in Exchange 2007. There are very powerfull and there are endless ideas of what you can do now ... in a very easy way compared to Event Sinks in Exchange 2003.
Any comments are most welcome ...
Note: This could be made to work with EventSinks also in Exchange 2003, but I dont have the knowledge nor time to do it ... if someone makes it, I will happily post it here.
Files
Old version will be taken offline and will not be available.