Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
langxml
titleSender (provider) endpoint
<mail:sender service="test:myMailService" 
             endpoint="senderEndpoint"
             sender="no-reply@servicemix.org" 
             connection="imapsmtp://lhein@testserver:143?password=myPass" /> 
Code Block
langxml
titlePolling (consumer) endpoint
<mail:poller service="test:myMailService"
             endpoint="pollerEndpoint"
             targetService="test:myMailProcessor"
             period="10000"
             connection="imap://lhein@testserver:143/INBOX?password=myPass"
             deleteProcessedMessages="false"
             processOnlyUnseenMessages="true" />

...

Info
titlePoller endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Default

connection

string

sets the connection information

null (must be spec'd)

deleteProcessedMessages

boolean

delete mail from server when it is processed

false

processOnlyUnseenMessages

boolean

process only mails which are new (unseen)

true

marshaler

class

org.apache.servicemix.mail.marshaler.AMailMarshalerSupport

DefaultMailMarshaler

debugMode

boolean

sets the debug mode for the javamail api

false

customTrustManagers

string

sets one or more custom trust managers for use with ssl

null

 
 

The connection uri

The connection uri has to be specified in the following way:

No Format
 
Template: <protocol>://<user>@<host>[:<port>][/<folder>]?password=<password>
  OR  
Template: <protocol>://<host>[:<port>][/<folder>]?user=<user>;password=<password>

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

Info
titlePoller endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Description

protocol

the protocol to use (example: pop or imap)

user

the user name used to log into an account

host

the name or ip address of the mail server

port

the port number to use (optional)

folder

the folder to poll from (optional)

password

the password for the login

...

Info
titleSender endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Default

connection

string

sets the connection information

null (must be spec'd)

sender

string

defines the sender address of the mail

no-reply@localhost

marshaler

class

org.apache.servicemix.mail.marshaler.AMailMarshalerSupport

DefaultMailMarshaler

debugMode

boolean

sets the debug mode for the javamail api

false

customTrustManagers

string

sets one or more custom trust managers for use with ssl

null

 
 

For all xbean file endpoint configuration take a look at Xml schemas

...

Info
titleSpecial message properties
borderStylesolidbgColor='lighblue'

Constant

Value

Description

MSG_TAG_TO

org.apache.servicemix.mail.to

The address(es) the mail was or will be sent to.

MSG_TAG_CC

org.apache.servicemix.mail.cc

The addess(es) the mail was or will be sent to as copy.

MSG_TAG_BCC

org.apache.servicemix.mail.bcc

The addess(es) the mail will be sent to as blind copy.

MSG_TAG_FROM

org.apache.servicemix.mail.from

The addess the mail was received from or will be used as sender.

MSG_TAG_TEXT

org.apache.servicemix.mail.text

Contains the plain text content of the mail body if existing.

MSG_TAG_HTML

org.apache.servicemix.mail.html

Contains the html content of the mail body if existing.

MSG_TAG_SUBJECT

org.apache.servicemix.mail.subject

The subject of the received mail or for the mail to be sent.

MSG_TAG_REPLYTO

org.apache.servicemix.mail.replyto

The address to be used as reply-to.

MSG_TAG_SENTDATE

org.apache.servicemix.mail.sentdate

The date the email was sent.

MSG_TAG_ALTERNATIVE_CONTENT CONTENT0..n

org.apache.servicemix.mail.alternativecontent

Contains the alternative content of the mail body.

 
 

IMAPS and POP3S

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

The standard way

The standard way would be to just set the protocol in the connection uri to imaps instead of _imap. (same for smtp and pop3)
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)
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:
java -Djavax.net.ssl.trustStore=$HOME/.keystore ...
To import keys to that store you may use the keytool command.

The alternative way

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 DummyTrustManager.

Warning
titleSecurity Warning

Using the DummyTrustManager will provide you NO SECURITY AT ALL!

How to write a custom trust manager?

1. You need to subclass a trust manager which implements the TrustManager interface directly or indirectly. The constructor has to be parameterless.
2. You have to specify the attribute customTrustManagers 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.

Code Block
langxml
titleCustom Trust Manager Example

<mail:poller service="test:myMailService" 
             endpoint="pollEndpoint" 
             targetService="test:myMailProcessingService"
             period="10000"
             connection="imaps://lhein@imapserver/INBOX?password=mypass"
             deleteProcessedMessages="false"
             processOnlyUnseenMessages="true" 
             customTrustManagers="org.apache.servicemix.mail.security.DummyTrustManager" /> 

If you are not using a secure protocol the attribute customTrustManager will be ignored at all.

How to debug if I got problems connecting to the mail server?

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

Using template engines

TODO

Velocity

TODO