blob: e3e949be23ce0184663b088d9fa857d641900f34 [file] [log] [blame]
<!-- saved from url=(0022)http://internet.e-mail -->
<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 tunneled into the Axis engine.</p>
<p>Mail transport can be used against a generic mail server or it can be used like a mailet. The simple mailet provided with Axis2 will direct any message that is coming 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>
<p>To get started on the mail transport you need the following additional jar dependencies on the classpath.</p>
<ol>
<li>javamail</li>
<li>activation</li>
</ol>
<p>We use the Geronimo version of these jars. Specificaly we are using geronimo-spec-javamail-[version].jar and geronimo-spec-activation-[version].jar. These will be downloaded by maven when you run the maven build.</p>
<h2>Transport Sender</h2>
<p>You need to have a mail account to activate the mail functionality. This can either be a generic mail server or you can start up a james mail server. The 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>The mail Listener can be activated by adding the following entry to the axis2.xml file.</p>
<source><pre>
&lt;transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener"&gt;
&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 the 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 can be started from the command line using the following piece of code when all the needed jars are in the class path.</p>
<p><code>java org.apache.axis2.transport.mail.server.MailServer</code></p>
<p>The 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>