servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache ServiceMix > servicemix-mail
Date Fri, 10 Sep 2010 08:14:01 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/13/_/styles/combined.css?spaceKey=SM&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SM/servicemix-mail">servicemix-mail</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~lhein">Lars
Heinemann</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| MSG_TAG_TEXT			| org.apache.servicemix.mail.text
| Contains the plain text content of the mail body if existing.| <br>| MSG_TAG_HTML
		| org.apache.servicemix.mail.html	| Contains the html content of the mail body if existing.
(or put the HTML as the content of the NMsg)| <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
MSG_TAG_USER                  | org.apache.servicemix.mail.username   | Contains the user
name to use for authentication to outgoing mail server. | <br>| MSG_TAG_PASSWORD   
          | org.apache.servicemix.mail.password   | Contains the user password to use for
authentication to outgoing mail server. | <br>| MSG_TAG_HOST                  | org.apache.servicemix.mail.host
      | Contains the host name of the mail server to use for outgoing mail. | <br>|
MSG_TAG_PROTOCOL              | org.apache.servicemix.mail.protocol   | Contains the protocol
to use for the outgoing mail. | <br>| MSG_TAG_PORT                  | org.apache.servicemix.mail.port
      | Contains the port number to use for the outgoing mail server. | <br></td></tr>
            <tr><td class="diff-unchanged" >{info} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="servicemix-mail-ServiceMixMail"></a>ServiceMix Mail</h1>

<p>The ServiceMix Mail component provides support for receiving and sending mails via
the enterprise service bus. </p>

<h2><a name="servicemix-mail-MavenArchetype"></a>Maven Archetype</h2>

<p>You can use Maven servicemix-mail-service-unit archetype to create a service unit:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn archetype:create \
    -DarchetypeGroupId=org.apache.servicemix.tooling \
    -DarchetypeArtifactId=servicemix-mail-service-unit \
    -DarchetypeVersion=2010.01 \
    -DgroupId=your.group.id \
    -DartifactId=your.artifact.id \
    -Dversion=your-version
</pre>
</div></div>

<h2><a name="servicemix-mail-EndpointsConfiguration"></a>Endpoints Configuration</h2>

<h3><a name="servicemix-mail-PollerEndpoint%28Consumer%29"></a>Poller Endpoint
(Consumer)</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Polling (Consumer) Endpoint</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
&lt;mail:poller service=<span class="code-quote">"test:myMailService"</span>
             endpoint=<span class="code-quote">"pollerEndpoint"</span>
             targetService=<span class="code-quote">"test:myMailProcessor"</span>
             period=<span class="code-quote">"10000"</span>
             connection=<span class="code-quote">"imap://user@testserver:143/INBOX?password=myPass"</span>
             deleteProcessedMessages=<span class="code-quote">"false"</span>
             processOnlyUnseenMessages=<span class="code-quote">"true"</span>
/&gt;
</pre>
</div></div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Message Exchange Pattern</b><br
/>The poller endpoint will only generate InOnly exchanges.</td></tr></table></div>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Poller Endpoint
Attributes</b><br /><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name 		                </th>
<th class='confluenceTh'> Type 	</th>
<th class='confluenceTh'> Description 							        </th>
<th class='confluenceTh'> Default 		</th>
</tr>
<tr>
<td class='confluenceTd'> connection		                </td>
<td class='confluenceTd'> string	</td>
<td class='confluenceTd'> sets the connection information				        </td>
<td class='confluenceTd'> null (must be spec'd)	</td>
</tr>
<tr>
<td class='confluenceTd'> deleteProcessedMessages		</td>
<td class='confluenceTd'> boolean	</td>
<td class='confluenceTd'> delete mail from server when it is processed				</td>
<td class='confluenceTd'> false			</td>
</tr>
<tr>
<td class='confluenceTd'> processOnlyUnseenMessages		</td>
<td class='confluenceTd'> boolean	</td>
<td class='confluenceTd'> process only mails which are new (unseen)				</td>
<td class='confluenceTd'> true			</td>
</tr>
<tr>
<td class='confluenceTd'> marshaler		                </td>
<td class='confluenceTd'> class		</td>
<td class='confluenceTd'> org.apache.servicemix.mail.marshaler.AbstractMailMarshaler
	</td>
<td class='confluenceTd'> DefaultMailMarshaler	</td>
</tr>
<tr>
<td class='confluenceTd'> maxFetchSize                          </td>
<td class='confluenceTd'> int           </td>
<td class='confluenceTd'> sets max amount of mails to fetch, -1 means no limit     
            </td>
<td class='confluenceTd'> -1                    </td>
</tr>
<tr>
<td class='confluenceTd'> debugMode		                </td>
<td class='confluenceTd'> boolean	</td>
<td class='confluenceTd'> sets the debug mode for the javamail api		               
</td>
<td class='confluenceTd'> false			</td>
</tr>
<tr>
<td class='confluenceTd'> customTrustManagers	                </td>
<td class='confluenceTd'> string	</td>
<td class='confluenceTd'> sets one or more custom trust managers for use with ssl		</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> storage	                        </td>
<td class='confluenceTd'> class 	</td>
<td class='confluenceTd'> sets the storage to use for remembering the seen messages
when using pop protocol (org.apache.servicemix.store.Store)	 	</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> customProperties                      </td>
<td class='confluenceTd'> java.util.Map </td>
<td class='confluenceTd'> a map of custom properties for the connection            
            </td>
<td class='confluenceTd'> null                  </td>
</tr>
</tbody></table>
</div>
</td></tr></table></div>

<p>The DefaultMailMarshaler (used if no other is set) will convert in the following
way:</p>
<ul class="alternate" type="square">
	<li>Headers of the mail are copied 1:1 into the message properties (and concatenated
if needed)</li>
	<li>if the mail has only plain text, the content will be put to property MSG_TAG_TEXT
and to the message content</li>
	<li>if the mail has only html, the content will be put to property MSG_TAG_HTML and
to the message content</li>
	<li>if the mail has both plain text and html, then both will be put to the right property
and the content of the message will be the plain text</li>
	<li>attachments are copied 1:1 from mail to message</li>
</ul>


<h3><a name="servicemix-mail-TheconnectionURI"></a>The connection URI</h3>

<p>The connection uri has to be specified in the following way:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre> 
Template: &lt;protocol&gt;://&lt;user&gt;@&lt;host&gt;[:&lt;port&gt;][/&lt;folder&gt;]?password=&lt;password&gt;
  OR  
Template: &lt;protocol&gt;://&lt;host&gt;[:&lt;port&gt;][/&lt;folder&gt;]?user=&lt;user&gt;;password=&lt;password&gt;


Example: 
   imap://user@imapserver:143/INBOX?password=mypass
   pop3://pop3server/INBOX?user=me@myhome.org;password=mypass

</pre>
</div></div> 

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>URI Attributes</b><br
/><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name 		</th>
<th class='confluenceTh'> Description				</th>
</tr>
<tr>
<td class='confluenceTd'> protocol		</td>
<td class='confluenceTd'> the protocol to use (example: pop3 or imap)</td>
</tr>
<tr>
<td class='confluenceTd'> user			</td>
<td class='confluenceTd'> the user name used to log into an account</td>
</tr>
<tr>
<td class='confluenceTd'> host			</td>
<td class='confluenceTd'> the name or ip address of the mail server</td>
</tr>
<tr>
<td class='confluenceTd'> port			</td>
<td class='confluenceTd'> the port number to use (optional)</td>
</tr>
<tr>
<td class='confluenceTd'> folder		</td>
<td class='confluenceTd'> the folder to poll from (optional)</td>
</tr>
<tr>
<td class='confluenceTd'> password		</td>
<td class='confluenceTd'> the password for the login</td>
</tr>
</tbody></table>
</div>
</td></tr></table></div>
<p>&nbsp;<br/>
&nbsp;</p>

<h3><a name="servicemix-mail-SenderEndpoint%28Provider%29"></a>Sender Endpoint
(Provider)</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Sender (provider) endpoint</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
&lt;mail:sender service=<span class="code-quote">"test:myMailService"</span>

             endpoint=<span class="code-quote">"senderEndpoint"</span>
             sender=<span class="code-quote">"no-reply@servicemix.org"</span>
             receiver=<span class="code-quote">"testreceiver@targethost.com"</span>
             connection=<span class="code-quote">"smtp://lhein@testserver?password=myPass"</span>
/&gt; 
</pre>
</div></div>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Sender Endpoint
Attributes</b><br /><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name 		</th>
<th class='confluenceTh'> Type 	</th>
<th class='confluenceTh'> Description 							</th>
<th class='confluenceTh'> Default 		</th>
</tr>
<tr>
<td class='confluenceTd'> connection		</td>
<td class='confluenceTd'> string	</td>
<td class='confluenceTd'> sets the connection information				</td>
<td class='confluenceTd'> null (must be spec'd)	</td>
</tr>
<tr>
<td class='confluenceTd'> sender		</td>
<td class='confluenceTd'> string	</td>
<td class='confluenceTd'> defines the sender address of the mail			</td>
<td class='confluenceTd'> no-reply@localhost	</td>
</tr>
<tr>
<td class='confluenceTd'> receiver		</td>
<td class='confluenceTd'> string	</td>
<td class='confluenceTd'> defines the receiver address of the mail			</td>
<td class='confluenceTd'> null			</td>
</tr>
<tr>
<td class='confluenceTd'> marshaler		</td>
<td class='confluenceTd'> class		</td>
<td class='confluenceTd'> org.apache.servicemix.mail.marshaler.AbstractMailMarshaler
</td>
<td class='confluenceTd'> DefaultMailMarshaler	</td>
</tr>
<tr>
<td class='confluenceTd'> debugMode		</td>
<td class='confluenceTd'> boolean	</td>
<td class='confluenceTd'> sets the debug mode for the javamail api		        </td>
<td class='confluenceTd'> false			</td>
</tr>
<tr>
<td class='confluenceTd'> ignoreMessageProperties </td>
<td class='confluenceTd'> java.util.List </td>
<td class='confluenceTd'> a list of properties of the IN message which will be ignored
       </td>
<td class='confluenceTd'> false                 </td>
</tr>
<tr>
<td class='confluenceTd'> customProperties      </td>
<td class='confluenceTd'> java.util.Map </td>
<td class='confluenceTd'> a map of custom properties for the connection            
    </td>
<td class='confluenceTd'> null                  </td>
</tr>
<tr>
<td class='confluenceTd'> customTrustManagers	</td>
<td class='confluenceTd'> string	</td>
<td class='confluenceTd'> sets one or more custom trust managers for use with ssl	</td>
<td class='confluenceTd'> null			</td>
</tr>
</tbody></table>
</div>
</td></tr></table></div>

<p>The DefaultMailMarshaler (used if no other is set) will convert in the following
way:</p>
<ul class="alternate" type="square">
	<li>all properties of the message MSG_TAG_xxxx will be evaluated and used for preparing
the mail</li>
	<li>if MSG_TAG_TEXT and/or MSG_TAG_HTML are specified, then the content will be used
for preparing the mail content</li>
	<li>if there are no MSG_TAG_TEXT and MSG_TAG_HTML properties, the content of the message
will be parsed and converted to the mail body as plain text or html content</li>
	<li>attachments are copied 1:1 from mail to message</li>
</ul>


<h4><a name="servicemix-mail-Howisthesenderdetermined%3F"></a>How is the
sender determined?</h4>

<p>If there is a preconfigured sender for the endpoint from xbean.xml, it will be used<br/>
else if MSG_TAG_FROM is defined in the message properties, then it will be used<br/>
else the method getDefaultSender() of the marshaler is invoked</p>


<h4><a name="servicemix-mail-Howisthereceiverdetermined%3F"></a>How is the
receiver determined?</h4>
<p>If there is a TO property in the normalized message, then it will be used. <br/>
If this property is missing, then the pre-configured receiver will be used.</p>


<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Common pitfall
regarding the receiver</b><br />If you are just setting up a mail-bridge (means
just a poller connected to a sender for mail forwarding) you will need<br/>
to provide a sender property <b>ignoreMessageProperties</b> as <b>List</b>,
containing a list of to ignore message properties. <br/>
Inside you should at least define the <b>org.apache.servicemix.mail.to</b> value,
otherwise the receiver will be the receiver of the original mail. <br/>
That would just forward the original mail to the account you are polling from generating a
nice mail loop. Be warned!</td></tr></table></div>

<h2><a name="servicemix-mail-Cookbookrecipes"></a>Cookbook recipes</h2>
<ul><li><a href="/confluence/display/SM/Simple+Mail+Forwarding" title="Simple
Mail Forwarding">Simple Mail Forwarding</a> &mdash; <span class="smalltext">implement
a simple mail forwarder</span></li></ul>

<h2><a name="servicemix-mail-HowtousecustomProperties"></a>How to use customProperties</h2>

<p>Via this attribute you can provide a map of properties which will be applied to the
connection properties. Doing so enables you to<br/>
completely configure the connection properties.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Polling endpoint with ignored TOP headers (same
is also for sender)</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;beans <span class="code-keyword">xmlns:mail</span>=<span class="code-quote">"http://servicemix.apache.org/mail/1.0"</span>
       <span class="code-keyword">xmlns:test</span>=<span class="code-quote">"http://www.servicemix.org/example"</span>
       <span class="code-keyword">xmlns:util</span>=<span class="code-quote">"http://www.springframework.org/schema/util"</span>&gt;

&lt;mail:poller service=<span class="code-quote">"test:myMailService"</span>
             endpoint=<span class="code-quote">"pollerEndpoint"</span>
             targetService=<span class="code-quote">"test:myMailProcessor"</span>
             period=<span class="code-quote">"10000"</span>
             connection=<span class="code-quote">"imap://lhein@testserver:143/INBOX?password=myPass"</span>
             deleteProcessedMessages=<span class="code-quote">"false"</span>
             processOnlyUnseenMessages=<span class="code-quote">"true"</span>

             customProperties=<span class="code-quote">"#customProps"</span>/&gt;

  <span class="code-tag">&lt;util:map id=<span class="code-quote">"customProps"</span>&gt;</span>
    <span class="code-tag">&lt;entry key=<span class="code-quote">"mail.pop3.forgettopheaders"</span>
value=<span class="code-quote">"true"</span> /&gt;</span>
  <span class="code-tag">&lt;/util:map&gt;</span>

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<p>For a list of properties used by the SUN implementation influencing the connection
have a look at the Mail API documentation:<br/>
<a href="http://java.sun.com/products/javamail/javadocs/overview-summary.html" class="external-link"
rel="nofollow">http://java.sun.com/products/javamail/javadocs/overview-summary.html</a><br/>
Have especially a look at the protocol specific package summaries.</p>

<h4><a name="servicemix-mail-HowtouseignoreMessageProperties"></a>How to
use ignoreMessageProperties</h4>
<p>Via this property you can provide a list of properties of the normalized in message
which will be set to null<br/>
before marshaling it. This will enable you for example to have a simple email forward bridge
with a poller and a <br/>
sender which will forward the received message to a new email address. Without skipping at
least the TO address property <br/>
the mail would be sent again to the account you are polling from (see how the receiver is
determined).</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Sending endpoint with skipping the adress fields</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;beans <span class="code-keyword">xmlns:mail</span>=<span class="code-quote">"http://servicemix.apache.org/mail/1.0"</span>
       <span class="code-keyword">xmlns:test</span>=<span class="code-quote">"http://www.servicemix.org/example"</span>
       <span class="code-keyword">xmlns:util</span>=<span class="code-quote">"http://www.springframework.org/schema/util"</span>&gt;

  &lt;mail:sender service=<span class="code-quote">"test:myMailService"</span>

             endpoint=<span class="code-quote">"senderEndpoint"</span>
             sender=<span class="code-quote">"no-reply@servicemix.org"</span>
             receiver=<span class="code-quote">"testreceiver@targethost.com"</span>
             connection=<span class="code-quote">"smtp://lhein@testserver?password=myPass"</span>

             ignoreMessageProperties=<span class="code-quote">"#ignoreProps"</span>
/&gt; 

  <span class="code-tag">&lt;util:list id=<span class="code-quote">"ignoreProps"</span>&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.mail.to<span
class="code-tag">&lt;/value&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.mail.cc<span
class="code-tag">&lt;/value&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.mail.bcc<span
class="code-tag">&lt;/value&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.mail.from<span
class="code-tag">&lt;/value&gt;</span>
    <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.mail.replyto<span
class="code-tag">&lt;/value&gt;</span>
  <span class="code-tag">&lt;/util:list&gt;</span>

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<p>For all xbean file endpoint configuration take a look at <a href="/confluence/display/SM/Xml+schemas"
title="Xml schemas">Xml schemas</a></p>

<h2><a name="servicemix-mail-Marshalers"></a>Marshalers</h2>

<p>You can write your own marshalers for conversion between mail and normalized message
and vice versa.<br/>
To do this you simply need to subclass the <b>org.apache.servicemix.mail.marshaler.AbstractMailMarshaler</b>
or even the<br/>
DefaultMailMarshaler if you don't want to start from scratch.</p>

<h3><a name="servicemix-mail-SubclassingtheAbstractMailMarshaler"></a>Subclassing
the AbstractMailMarshaler </h3>
<p>For providing your own marshaler you only need to implement two methods:</p>

<h4><a name="servicemix-mail-convertMailToJBI%28...%29"></a>convertMailToJBI(...)</h4>
<p>This method is responsible for translating a received mail message into a jbi compliant
normalized message ready to be sent to the bus.</p>

<h4><a name="servicemix-mail-convertJBIToMail%28...%29"></a>convertJBIToMail(...)</h4>
<p>This method is responsible for translating a received normalized message into a mail
message ready to be sent to the mail server.</p>

<p>After finishing your marshaler you can simply configure your endpoints to use it:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Marshaler example</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
&lt;mail:poller service=<span class="code-quote">"test:myMailService"</span>

             endpoint=<span class="code-quote">"senderEndpoint"</span>
             sender=<span class="code-quote">"no-reply@servicemix.org"</span>

             connection=<span class="code-quote">"imap://lhein@testserver:143?password=myPass"</span>
&gt; 

    <span class="code-tag">&lt;property name=<span class="code-quote">"marshaler"</span>&gt;</span>
        <span class="code-tag">&lt;bean class=<span class="code-quote">"com.mycompany.MyMailMarshaler"</span>
/&gt;</span>
    <span class="code-tag">&lt;/property&gt;</span>

<span class="code-tag">&lt;/mail:poller&gt;</span>
</pre>
</div></div>

<h2><a name="servicemix-mail-Mappingofheadersandproperties"></a>Mapping
of headers and properties</h2>

<p>All mail headers are mapped (nearly) one-to-one into message properties. If there
are multiple mail headers with the same name, then the values will be concatenated and separated
by the semicolon (<tt>;</tt>-character).</p>

<p>There are some more important properties which affect the handling of the message
/ mail (constants are defined in AbstractMailMarshaler):</p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Special message
properties</b><br /><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Constant 			</th>
<th class='confluenceTh'> String-Value				</th>
<th class='confluenceTh'> Description 					</th>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_TO			</td>
<td class='confluenceTd'> org.apache.servicemix.mail.to		</td>
<td class='confluenceTd'> The address(es) the mail was or will be sent to.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_CC			</td>
<td class='confluenceTd'> org.apache.servicemix.mail.cc		</td>
<td class='confluenceTd'> The addess(es) the mail was or will be sent to as copy.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_BCC			</td>
<td class='confluenceTd'> org.apache.servicemix.mail.bcc	</td>
<td class='confluenceTd'> The addess(es) the mail will be sent to as blind copy.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_FROM			</td>
<td class='confluenceTd'> org.apache.servicemix.mail.from	</td>
<td class='confluenceTd'> The addess the mail was received from or will be used as sender.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_SUBJECT		</td>
<td class='confluenceTd'> org.apache.servicemix.mail.subject	</td>
<td class='confluenceTd'> The subject of the received mail or for the mail to be sent.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_REPLYTO		</td>
<td class='confluenceTd'> org.apache.servicemix.mail.replyto	</td>
<td class='confluenceTd'> The address to be used as reply-to.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_SENTDATE		</td>
<td class='confluenceTd'> org.apache.servicemix.mail.sentdate	</td>
<td class='confluenceTd'> The date the email was sent.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_MAIL_CONTENT_TYPE	</td>
<td class='confluenceTd'> org.apache.servicemix.mail.type	</td>
<td class='confluenceTd'> The mail mime type.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_MAIL_CHARSET		</td>
<td class='confluenceTd'> org.apache.servicemix.mail.charset	</td>
<td class='confluenceTd'> The charset to use.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_MAIL_USE_INLINE_ATTACHMENTS	</td>
<td class='confluenceTd'> org.apache.servicemix.mail.attachments.inline	</td>
<td class='confluenceTd'> Should attachments be set as inline</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_TEXT			</td>
<td class='confluenceTd'> org.apache.servicemix.mail.text	</td>
<td class='confluenceTd'> Contains the plain text content of the mail body if existing.</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_HTML			</td>
<td class='confluenceTd'> org.apache.servicemix.mail.html	</td>
<td class='confluenceTd'> Contains the html content of the mail body if existing. (or
put the HTML as the content of the NMsg)</td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_USER                  </td>
<td class='confluenceTd'> org.apache.servicemix.mail.username   </td>
<td class='confluenceTd'> Contains the user name to use for authentication to outgoing
mail server. </td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_PASSWORD              </td>
<td class='confluenceTd'> org.apache.servicemix.mail.password   </td>
<td class='confluenceTd'> Contains the user password to use for authentication to outgoing
mail server. </td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_HOST                  </td>
<td class='confluenceTd'> org.apache.servicemix.mail.host       </td>
<td class='confluenceTd'> Contains the host name of the mail server to use for outgoing
mail. </td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_PROTOCOL              </td>
<td class='confluenceTd'> org.apache.servicemix.mail.protocol   </td>
<td class='confluenceTd'> Contains the protocol to use for the outgoing mail. </td>
</tr>
<tr>
<td class='confluenceTd'> MSG_TAG_PORT                  </td>
<td class='confluenceTd'> org.apache.servicemix.mail.port       </td>
<td class='confluenceTd'> Contains the port number to use for the outgoing mail server.
</td>
</tr>
</tbody></table>
</div>
</td></tr></table></div>

<h3><a name="servicemix-mail-MailContentTypes"></a>Mail Content Types</h3>

<p>These are the available content types:</p>
<ul>
	<li>text/plain</li>
	<li>text/html</li>
	<li>text/xml</li>
	<li>multipart/*</li>
	<li>multipart/mixed</li>
	<li>multipart/alternative</li>
	<li>unknown</li>
</ul>


<p>On incoming mails you may evaluate this property on the normalized message to find
out which kind of mime type the mail had. On outgoing mails you can control the mime type
to use for the mail. If you don't set the content type it will be auto-sensed by the marshaler.<br/>
&nbsp;<br/>
&nbsp;</p>

<h2><a name="servicemix-mail-IMAPSandPOP3S"></a>IMAPS and POP3S</h2>

<p>If you want to use secure protocols like IMAPS or POP3S you have several oportunities
to do that.</p>


<h3><a name="servicemix-mail-Thestandardway"></a>The standard way</h3>

<p>The standard way would be to just set the protocol in the connection uri to <em>imaps</em>
instead of <em>imap</em>. (same for smtp and pop3)<br/>
Java will then try to verify the certificate of the mail server by following the chain of
certificates signing the server's certificate back to one of these well known CA certificates
specified in the default java keystore file. (see SSLNOTES.txt of JavaMail API for details)<br/>
If the certificate has no chain (is self signed) then this chain following is impossible.
For this case you have to specify the key store to use via system properties:<br/>
   <em>java -Djavax.net.ssl.trustStore=$HOME/.keystore ...</em><br/>
To import keys to that store you may use the <em>keytool</em> command.</p>


<h3><a name="servicemix-mail-Thealternativeway"></a>The alternative way</h3>

<p>You have the possibility to write your own TrustManager and let the component use
this custom trust manager. If you want no verification of the servers certificate at all then
you can use the shipped <em>DummyTrustManager</em>.</p>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Security
Warning</b><br />Using the <b>DummyTrustManager</b> will provide you
<b>NO SECURITY AT ALL!</b></td></tr></table></div>

<h4><a name="servicemix-mail-Howtowriteacustomtrustmanager%3F"></a>How to
write a custom trust manager?</h4>

<p>1. You need to subclass a trust manager which implements the TrustManager interface
directly or indirectly. The constructor has to be parameterless.<br/>
2. You have to specify the attribute <em>customTrustManagers</em> in the endpoint
configuration inside your xbean.xml file. The content will be the full name of the class including
the package name (for example: customTrustManagers="com.mycompany.mypackage.MyTrustManager").
If you want to define more then one just use the semicolon ( ; ) to separate the class names.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Custom Trust Manager Example</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
&lt;mail:poller service=<span class="code-quote">"test:myMailService"</span>

             endpoint=<span class="code-quote">"pollEndpoint"</span> 
             targetService=<span class="code-quote">"test:myMailProcessingService"</span>
             period=<span class="code-quote">"10000"</span>
             connection=<span class="code-quote">"imaps://lhein@imapserver/INBOX?password=mypass"</span>
             deleteProcessedMessages=<span class="code-quote">"false"</span>
             processOnlyUnseenMessages=<span class="code-quote">"true"</span>

             customTrustManagers=<span class="code-quote">"org.apache.servicemix.mail.security.DummyTrustManager"</span>
/&gt; 
</pre>
</div></div>

<p>If you are not using a secure protocol the attribute <em>customTrustManager</em>
will be ignored at all.</p>


<h2><a name="servicemix-mail-HowtodebugifIgotproblemsconnectingtothemailserver%3F"></a>How
to debug if I got problems connecting to the mail server?</h2>

<p>There is a additional attribute you may specify in the endpoints configuration. This
attribute is called <b>debugMode</b> and accepts the values <em>"true"</em>
or <em>"false"</em>. This will switch the JavaMail debug mode on or off providing
useful details to you via console or servicemix.log file.</p>


<h2><a name="servicemix-mail-Usingtemplateengines"></a>Using template engines</h2>

<p><em>NOTHING DONE YET...FEEL FREE TO HELP US OUT HERE.....TODO</em></p>

<h3><a name="servicemix-mail-Velocity"></a>Velocity</h3>

<p><em>NOTHING DONE YET...FEEL FREE TO HELP US OUT HERE.....TODO</em></p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SM/servicemix-mail">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=78388&revisedVersion=28&originalVersion=27">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SM/servicemix-mail?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message