blob: bc8fbb3698c41cde7112f12c2b6f5927cf472bec [file] [log] [blame]
<html>
<head>
<title>Mail transport</title>
</head>
<body><h1>Mail transport</h1>
<p>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.</p>
<p>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.</p>
<p></p>
<a>First you need following additional jar dependencies in the classpath, they can be found by downloading the <a href="http://java.sun.com/products/javamail/">JavaMail API</a> ans <a href="http://java.sun.com/products/javabeans/jaf/">JavaBeans Activation Framework</a>.</p>
<ol>
<LI>mail.jar&nbsp;(This contains com.sun.mail.* and javax.mail.*)</LI>
<LI>activation.jar</LI>
</ol>
<h2>Transport Sender</h2>
<p>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.</p>
<source>
<pre>
&lt;transportSender name="mail" class="org.apache.axis2.transport.mail.MailTransportSender"&gt;
&lt;parameter name="transport.mail.smtp.host" locked="xsd:false"&gt;smtp server host&lt;/parameter&gt;
&lt;parameter name="transport.mail.smtp.user" locked="xsd:false"&gt;user name&lt;/parameter&gt;
&lt;parameter name="transport.mail.smtp.password" locked="xsd:false"&gt;password&lt;/parameter&gt;
&lt;parameter name="transport.mail.smtp.port" locked="xsd:false"&gt;Port on the server for pop&lt;/parameter&gt;
&lt;/transportSender&gt;
</pre>
</source>
<h2>Transport Receiver</h2>
<p>You need a mail address that has pop access, the mail Listener can be activated by adding following entry to the axis2.xml file.</p>
<source><pre>
&lt;transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">
&lt;parameter name="transport.mail.pop3.host" locked="xsd:false"&gt;pop server host&lt;/parameter&gt;
&lt;parameter name="transport.mail.pop3.user" locked="xsd:false"&gt;user name&lt;/parameter&gt;
&lt;parameter name="transport.mail.pop3.password" locked="xsd:false"&gt;password&lt;/parameter&gt;
&lt;parameter name="transport.mail.pop3.port" locked="xsd:false"&gt;Port on the server for smtp&lt;/parameter&gt;
&lt;parameter name="transport.mail.replyToAddress" locked="xsd:false"&gt;email address&lt;/parameter&gt;
&lt;/transportReceiver&gt;
</pre></source>
<p>At the Client side if the Mail Listener is needed it is automatically started by Axis2.</p>
<h2>Using Mail transport in the Server Side</h2>
<p> 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.</p>
<source><pre>java org.apache.axis2.transport.mail.SimpleMailListener repository-directory</pre></source>
<h2>Using Mail transport in the Client Side</h2>
<p>Following code segment shows how to send a oneway SOAP message using the mail transport, this need the Transport Sender configured.</p>
<source>
<pre>
OMElement payload = ....
MessageSender sender = new MessageSender(serviceContext);
sender.setTo(targetEPR);
sender.setSenderTransport(Constants.TRANSPORT_MAIL);
sender.send(operationName.getLocalPart(), payload);
</pre>
</source>
<h2>Configure James as SMTP and POP server</h2>
<p>Download the <a href="http://james.apache.org/">Apache James</a> and start James, connect to the James via telnet for administrator James with following code
</p>
<source>
<pre>
$telnet 127.0.0.1 4555
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
JAMES Remote Administration Tool 2.2.0
Please enter your login and password
Login id:
root
Password:
root
Welcome root. HELP for a list of commands
</pre>
</source>
<p>Add users to James</p>
<source>
<pre>
adduser axis2-server axis2
User axis2-server added
adduser axis2-client axis2
User axis2-client added
Connection closed by foreign host.
</pre>
</source>
<p>Now James is up and running with the accounts</p>
<h2>Using the included mail server</h2>
<p>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.</p>
<p>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).</p>
<hr/>
<p>&nbsp;</p>
</body>
</html>