Mail — provides access to e-mail systems
The Mail component provides access to Email via Spring's Mail support and the underlying JavaMail system.
![]() | Warning |
---|---|
The Geronimo mail JAR (v1.6) has a bug when polling e-mails with attachments. It
cannot correctly identify the You can set your custom resolver on the |
![]() | Note |
---|---|
Because POP3 has some limitations, end users are encouraged to use IMAP when possible. |
![]() | Important |
---|---|
You can use a mock framework for unit testing, which allows you to test without
the need for a real mail server. However you should remember not to include
mock-mail when you go into production or in other environments where you need to
send mails to a real mail server. Just the presence of the
|
Mail endpoints can have one of the URI formats listed in Table 34, “Mail URI Formats”.
Table 34. Mail URI Formats
Mail Protocol | URI Format |
---|---|
SMTP |
smtp(s)://[
|
POP3 |
pop3(s)://[
|
IMAP |
imap(s)://[
|
Mail endpoints also supports secure variants of these protocols that are layered over
SSL. You can enable the secure protocols by adding s
to the
scheme.
Table 35, “Default mail port numbers” lists the default port numbers that are used if the port number is omitted.
Table 35. Default mail port numbers
Protocol | Default Port Number |
---|---|
SMTP | 25 |
SMTPS | 465 |
POP3 | 110 |
POP3S | 995 |
IMAP | 143 |
IMAPS | 993 |
Table 36, “Mail endpoint options” describes the options for Mail endpoints.
Table 36. Mail endpoint options
Property | Default | Description |
---|---|---|
host
| The host name or IP address to connect to. | |
port
| See Table 35, “Default mail port numbers” | The TCP port number to connect on. |
username
| The user name on the email server. | |
password
| The password on the email server. | |
ignoreUriScheme
|
false
| If false , Apache Camel uses the scheme to determine
the transport protocol (POP, IMAP, SMTP etc.) |
defaultEncoding
| The default encoding to use for Mime Messages. | |
contentType
|
text/plain
| The mail message content type. Use text/html for
HTML mails. |
folderName
|
INBOX
| The folder to poll. |
to
|
| The recipients. Separate multiple email addresses with a comma. |
replyTo
|
| The Reply-To recipients (receivers of the response mail). Separate multiple email addresses with a comma. |
CC
| The CC recipients. Separate multiple email addresses with a comma. | |
BCC
| The BCC recipients. Separate multiple email addresses with a comma. | |
from
|
camel@localhost
| The FROM email address. |
subject
| The Subject of the message being sent. Note: Setting the subject in the header takes precedence over this option. | |
delete
|
false
| Deletes the messages after they have been processed. This is done by
setting the DELETED flag on the mail message. If
false , the SEEN flag is set
instead. |
unseen
|
true
| Is used to only fetch unseen(new) messages. POP3 does not support the
SEEN flag. |
fetchSize
|
-1
| Specifies the maximum number of messages to consume during a poll.The
default value of -1 means all available messages will be
consumed. Setting the value to 0 means Apache Camel will not
consume any messages. |
alternativeBodyHeader
|
CamelMailAlternativeBody
| Specifies the key to an IN message header that contains an
alternative email body. For example, if you send emails in
text/html format and want to provide an
alternative mail body for non-HTML email clients, set the alternative
mail body with this key as a header. |
debugMode
|
false
| Specifies if debug mode is enabled on the underlying mail framework.
The SUN Mail framework logs the debug messages to
System.out by default. |
connectionTimeout
|
30000
| The connection timeout can be configured in milliseconds. |
consumer.initialDelay
|
1000
| Milliseconds before the polling starts. |
consumer.delay
|
60000
| Specifies the consumer delay in milliseconds. |
consumer.useFixedDelay
|
false
| Set to true to use a fixed delay between polls,
otherwise fixed rate is used. See ScheduledExecutorService in JDK for details. |
mail.
| You can set any additional java mail properties. | |
maxMessagesPerPoll
|
0
| Specifies the maximum number of messages to gather per poll. The
default value of 0 (or a negative value) disables this
option. |
javaMailSender
| Specifies a custom implementation of the Spring
JavaMailSender interface in order to
use a custom email implementation. If none provided, Apache Camel uses the
default Spring JavaMailSenderImpl
implementation. | |
ignoreUnsupportedCharset
|
false
| Option to let Apache Camel ignore unsupported charsets in the local
JVM when sending mails. If the charset is unsupported then
charset=XXX is removed from the
content-type and it relies on the platform
default instead. |
The underlying mail framework is responsible for providing SSL support. Apache Camel
uses SUN JavaMail, which only trusts certificates issued by well known Certificate
Authorities. So if you issue your own certificate, you have to import it into the local
Java keystore file (see SSLNOTES.txt
in JavaMail for details).
SUN JavaMail is used under the hood for consuming and producing mails. We encourage end-users to consult these references when using either POP3 or IMAP protocol. Note particularly that POP3 has a much more limited set of features than IMAP.
And generally about the MAIL Flags