msg332 developing transport event messaging solutions for windows and exchange max ciccotosto...
TRANSCRIPT
MSG332
Developing Transport Event Messaging Solutions for Windows and Exchange
Max Ciccotosto
Program Manager - Exchange
Microsoft Corporation
AgendaSinks Overview and Basics
SMTP Service
What can you do with events?
Event model
Programming Language Support
AdvancedContent Conversion
Event registration
Interface descriptions
How to create transport and protocol event sinks
Exchange 2003 Vs. 2000
No changes in the Transport Infrastructure
Same events
Same interfaces
Exchange 2000 Sinks will work on 2003.
Added support for Retry
Improved documentation
Add recipient to messages from Internet
Windows SMTP Service
Store and forward relay
Mailing list (Distribution List or ‘DL’) expander
“Deliver” to Drop directory
“Pickup” from Pickup directory
Protocol And Transport EventsThe Goals
To allow the creation of a mail system on top of the Windows 2000 SMTP Service
To allow the extension of Exchange 2000 and Windows 2000 SMTP Service
Exchange
Exchange uses Windows SMTP ServiceExchange depends on SMTP Service
Exchange extends SMTP Service with events
Adds store (mailboxes), store driver (local delivery to store), a whole lot more
All messages go through events, even X.400 and RPC inbound/outbound
Protocol And Transport Events
Access to all message properties821, 822 and Transport specific properties
Many places in the code to “hook in”
COM based, C++ only
Support for Synch and Asynch events
Fast!
Event ModelProtocol Events
Extend SMTP protocol (ESMTP)
Modify existing SMTP protocol commands and responses
Transport EventsExtend message processing system (address resolution, restrictions processing, message routing)
Code runs on each message
Read/Write access to envelope and body
Executes in-process with IIS/SMTP
Uses For Protocol Events
Billing and charge-back based on number of connections, time of connections
Monitoring system via SMTP, implement new ESMTP commands
Provide new SMTP authentication methods
Provide RCPT checking
Custom anti-spam scripts
Uses For Transport Events
Forward all mail for a domain to a mailbox
Scan all inbound mail from the Internet for keyword, subject, attachment filename
Processing spans multiple internalmail systems
Virus checking
Spam (UCE) checkingStop mail with all numeric From: address
Stop mail with keywords in subject or body
Add a disclaimer to all outbound mail to the Internet
Apply custom restrictions
Event Overview
ProtocolCommand Events
TransportSubmission
Pre Categorizer
Categorizer
Post Categorizer
Routing
Store Driver
Transport CoreSMTP SMTP
ServiceServiceSMTP SMTP
ServiceService
PreCatPreCatEventEvent
PreCatPreCatEventEvent
PostCatPostCatEventEvent
PostCatPostCatEventEvent
Routing Routing EventEvent
Routing Routing EventEvent
SMTP SMTP ServiceServiceSMTP SMTP
ServiceService
Message Message CategorizerCategorizer
Message Message CategorizerCategorizer
Routing Engine Routing Engine (IMessageRouter)(IMessageRouter)Routing Engine Routing Engine
(IMessageRouter)(IMessageRouter)
Store Store SubmissionSubmission
Store Store SubmissionSubmission
MTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTS MTS OutOut
MTAMTAMTAMTA
CategorizerCategorizerEventsEvents
CategorizerCategorizerEventsEvents
Advanced Queuing
PreCatPreCatSinkSink
PreCatPreCatSinkSink
PostCatPostCatSinkSink
PostCatPostCatSinkSink
OnSubmissionOnSubmissionEventEvent
OnSubmissionOnSubmissionEventEvent
OnSubmissionOnSubmissionSinkSink
OnSubmissionOnSubmissionSinkSink
MTAMTAMTAMTA
Store Local Store Local DeliveryDelivery
Store Local Store Local DeliveryDelivery
MTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTSMTS InIn
MTSMTS InIn
Language Support
C++CDO_onArrival
OnSubmission EventScriptable, dual-interfacedCDO Message object gives easy access to message fields, attachments
Managed WrappersWrappers for all Transport ObjectsInterop abstractionhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmtps/html/writingmngsinks.asp
CDO Sink
Content Conversion
Exchange Content
No Content ConversionSMTP Inbound from Internet
SMTP Outbound to Internet
Content ConversionMAPI-Submitted
TNEF
Outlook 2000
Outlook Web Access
Bifurcation
Recipients:Recipients:
Content:Content:DefaultDefault
Recipients:Recipients:
Content:Content:DefaultDefault
MailMsg
Internal UserExternal User
BodyBodyBodyBody
Recipients:Recipients:
Content:Content:S-TNEFS-TNEF
Recipients:Recipients:
Content:Content:S-TNEFS-TNEF
Internal User
MailMsgRecipients:Recipients:
Content:Content:MIMEMIME
Recipients:Recipients:
Content:Content:MIMEMIME
External User
BodyBodyBodyBody
MailMsg
MAPIMAPIClientClientMAPIMAPIClientClient PrePre
CatCatPrePreCatCat
SMTPSMTPSMTPSMTPPostPostCatCat
PostPostCatCat
Exchange Issues
Not easy to modify content of MAPI/OWA-submitted messagesUNLESS it is going to “The Internet”
Design architecture so you don’t need to modify TNEF
Much easier to write Store Event sink to modify internal messages
Transport Events best suited for “the border”
Bottom LineBottom Line
Disclaimer Sink
Event Registration
Server Event Bindings
Stored in Metabase/smtpsvc/<instanceNumber>/EventManager
Event dispatcher (AQ) uses bindings to match sinks to events
Rules (“filter”)
Priority for each eventEvent sinks executed in order of priority
Same priority events executed in random order
Event Rules
Limit event call to certain messages
Case-insensitive
Can filter on MAIL FROM=, RCPT TO=, and EHLO=
Available on Submission, PreCat, PostCat events
Exchange tipTo catch MAPI-submitted messages, must have no filter rule
Event Rule Example
MAIL FROM= user1@domain;RCPT TO=user2@domain
Makes sink only fire on messages from user1@domain OR to user2@domain
Can use wildcards: @domain, user@foo*
Can have multiple RCPT TO:s, multiple MAIL FROM:s, multiple EHLOs; each is OR’d
Creating Bindings
1. Use smtpreg.vbs available in the Exchange SDK.
2. Do it yourself:SEO used to modify Metabase to create bindings
Tools for registration, de-registration, debugging (list binding)
VBScript, or can make sink self-registering via regsvr32 entry points
Troubleshooting: list bindings to see what is installed
Registering Sinks:SMTPREG
Protocol Events
Protocol Event Sinks
Sink implements one or more sink interfaces
Each sink fired based on what category the session is in
InboundOn Inbound Command, On Server Response
OutboundSession Start, Message Start, Per-Recipient,
Before Data, Session End
Protocol Event Sinks
ISmtpInCommandSinkCalled when inbound SMTP command is receivedISmtpOutCommandSinkCalled when outbound SMTP command is to be sentISmtpServerResponseSinkCalled when server responds to previously sent command
Protocol Event InterfacesGeneral Interface Property BagsIServer - Information about the SMTP Virtual Server
ISession – Information about the current SMTP Session
IMailMsgProperties – Information about the current message being received
Context InterfaceSystem-implemented interface
Sink can call to get and set information about commands and responses, set state
Transport Events
Transport Events
IMailTransportSubmissionOnSubmission event
Recipients should be added here (before categorizer-related events)
IMailTransportOnPreCategorizeShould be used to check recipient lists
All recipients should be present
IMailTransportOnPostCategorizeDLs will be expanded – actual recipients will be listed
Transport EventsRelated Functions
IMailTransportNotify Sink may return asynchronously, return MAIL_TRANSPORT_S_PENDING
That message will be halted and wait for callback via this function
Dispatcher will allow other messages to be processed until the thread pool limit
Transport EventsRelated Functions
IsCacheableIf not defined, sink instance deleted after exit
Overhead of CoCreateInstance() for each event raised if not cache-able
Sink must be re-entrant/thread-safeNo shared data without proper locking
Protocol events also can implement
IMailMsg
OnSubmission/PreCat/PostCat sinks get object IMailMsg
IMailMsgProperties objectMapContent() – maps content of message into memory
CopyContentToFile() – copies content of message to file
GetProperty()/PutProperty() – reads and writes properties
Many methods
Subsequent Sinks
Sink returns S_OKOther sinks at same or lower priority are called
Sink returns S_FALSEOther sinks at same or lower priority are not called
Recipe For Creating Transport
Event Sink
Creating Transport Sink
1. Implement sink interface method
2. Register event using smtpreg.vbs1. Register COM interface of sink in registry
2. Register interface in event binding database in metabase via SEO
3. Send messages through, watch it fire!
Managed Sink
Ask The ExpertsGet Your Questions Answered
Talk one-on-one with a community of your peers
Community Experts: Microsoft product teams, consultants and Tech*Ed speakers
Resources: whiteboards, internet, etc.
Location: in the middle of the Exhibit Hall
Hours: at least 12-3:30p every day
I will be at the ATE after this session
Community Resources
Community Resourceshttp://www.microsoft.com/communities/default.mspx
Most Valuable Professional (MVP)http://www.mvp.support.microsoft.com/
NewsgroupsConverse online with Microsoft Newsgroups, including Worldwidehttp://www.microsoft.com/communities/newsgroups/default.mspx
User GroupsMeet and learn with your peershttp://www.microsoft.com/communities/usergroups/default.mspx
Suggested Reading And Resources
The tools you need to put technology to work!The tools you need to put technology to work!
TITLETITLE AvailableAvailable
Microsoft® Exchange Server 2003 Microsoft® Exchange Server 2003 Administrator's Companion: 0-Administrator's Companion: 0-7356-1979-47356-1979-4
9/24/039/24/03
Microsoft® Windows® Server Microsoft® Windows® Server 2003 Administrator's 2003 Administrator's Companion: 0-7356-1367-2Companion: 0-7356-1367-2
TodayToday
Microsoft Press books are 20% off at the TechEd Bookstore
Also buy any TWO Microsoft Press books and get a FREE T-Shirt
Community Resources
Community Resourceshttp://www.microsoft.com/communities/default.mspx
Most Valuable Professional (MVP)http://www.mvp.support.microsoft.com/
NewsgroupsConverse online with Microsoft Newsgroups, including Worldwidehttp://www.microsoft.com/communities/newsgroups/default.mspx
User GroupsMeet and learn with your peershttp://www.microsoft.com/communities/usergroups/default.mspx
evaluationsevaluations
© 2003 Microsoft Corporation. All rights reserved.© 2003 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.