SMTP Listener

The SMTP listener is written as a SMTP event sink, as the SMTP Service processes the SMTP protocol, it can raise events to components that are configured to receive such events. The listener uses the OnArival event to examine the payload, pass the SOAP request off to the dispatcher, and generate a new email with the response.

Registering the listener with the SMTP Service

Each SMTP event sink needs to be registered with the SMTP service, in order to receive events, the following will register the SMTP SOAP listener with the SMTP service.
cscript smtpreg.vbs /add 1 OnArrival soapListener 4s4c.smtpSoap "rcpt to=soap-listener@debian.simonfell.com"
the 1 (after /add) is the virtual SMTP service, if you have the default single SMTP server install, this will be fine, if you have installed multiple virtual services, you'll need to select the correct one here. The last item "rcpt to=soap-listener@debian.simonfell.com" is a filter, the event will only be generated when the message passes this filter, in this case, the email must be addressed to soap-listener@debian.simonfell.com. You should replace this with the correct address for your installation.

To unregister the listener from the SMTP service, use (note that this is case sensitive)
cscript smtpreg.vbs /remove 1 OnArrival soapListener
you can use the following to display the registered sinks
cscript smtpreg.vbs /enum
The SMTP listener expects to find the config.xml file in the same directory as the smtpSoap.dll (typically 4s4c\smtp)

Testing the Listener

Once you've registered the event sink, you can test it by send an email to your soap listener address, with the following plain text email body
<SOAP-ENV:Envelope
    xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
    xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
    SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
 <SOAP-ENV:Body>
  <m:Add xmlns:m="http://simon.fell.com/calc">
   <a>16</a>
   <b>26</b>
  </m:Add>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
and it should email you back the response.
<?xml version="1.0"?>
<SOAP-ENV:Envelope  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema"
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <m:AddResponse xmlns:m="http://simon.fell.com/calc">
   <added xsi:type="xsd:int">42</added>
  </m:AddResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>



<<< Using the HTTP Listener      >>> The Dispatcher Component