The inner workings of the mail transport has two parts the transport Sender and the transport Listener. Here the transport Listener is a basic email client which will be on a loop checking for new messages for a particular email address. When an email comes in it will be tunnelled into the Axis engine.
When you think in terms of usage the mail transport in Axis2 can be used in two ways. It can be used against a generic mail server or it can be used like a mailet. The simple mailet provided will direct any message that is comming to a particular address into the Axis engine. The engine will process the message and will use the Transport sender to send the reply.
First you need following additional jar dependencies in the classpath, they can be found by downloading the JavaMail API ans JavaBeans Activation Framework.You need a mail account in a SMTP server, and Mail transport sender can be activated by adding following entry to the axis2.xml file.
You need a mail address that has pop access, the mail Listener can be activated by adding following entry to the axis2.xml file.
At the Client side if the Mail Listener is needed it is automatically started by Axis2.
If the Mail Listener is need to be started as the server it can be done with following command with the all the axis2 jars and the mail dependency jars in the classpath.
Following code segment shows how to send a oneway SOAP message using the mail transport, this need the Transport Sender configured.
Download the Apache James and start James, connect to the James via telnet for administrator James with following code
Add users to James
Now James is up and running with the accounts
The inbuilt mail server has to be started from code by providing a ConfigurationContext for the time being, because the standalone and the mailet functionality is tightly bound with the mailet functionality.
This server itself does not need any configuration or tinkering to work. A configurationContext and the ports to operate on are the only details needed. The server will store the mails in memory against the recipient till the recipient pops it from the server. To facilitate the use in *nix environments as a non root user the pop and smtp ports used by default config/test cases are (1024 + 25) and (1024 + 110).