Skip to content

Commit

Permalink
Merge pull request apache#2179 from rnetuka/entesb-20951
Browse files Browse the repository at this point in the history
[ENTESB-20951] Camel Mail Component doesn't use host/port information from session URI parameter
  • Loading branch information
rnetuka committed Apr 14, 2023
2 parents f649381 + 06ea930 commit 1c41a0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/camel-mail/src/main/docs/mail-component.adoc
Expand Up @@ -161,7 +161,7 @@ with the following path and query parameters:
| *headerFilterStrategy* (advanced) | To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter headers. | | HeaderFilterStrategy
| *ignoreUnsupportedCharset* (advanced) | Option to let Camel ignore unsupported charset in the local JVM when sending mails. If the charset is unsupported then charset=XXX (where XXX represents the unsupported charset) is removed from the content-type and it relies on the platform default instead. | false | boolean
| *ignoreUriScheme* (advanced) | Option to let Camel ignore unsupported charset in the local JVM when sending mails. If the charset is unsupported then charset=XXX (where XXX represents the unsupported charset) is removed from the content-type and it relies on the platform default instead. | false | boolean
| *session* (advanced) | Specifies the mail session that camel should use for all mail interactions. Useful in scenarios where mail sessions are created and managed by some other resource, such as a JavaEE container. If this is not specified, Camel automatically creates the mail session for you. | | Session
| *session* (advanced) | Specifies the mail session that camel should use for all mail interactions. Useful in scenarios where mail sessions are created and managed by some other resource, such as a JavaEE container. When using a custom mail session, then the hostname and port from the mail session will be used (if configured on the session). | | Session
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
| *useInlineAttachments* (advanced) | Whether to use disposition inline or attachment. | false | boolean
| *idempotentRepository* (filter) | A pluggable repository org.apache.camel.spi.IdempotentRepository which allows to cluster consuming from the same mailbox, and let the repository coordinate whether a mail message is valid for the consumer to process. By default no repository is in use. | | IdempotentRepository
Expand Down
Expand Up @@ -205,6 +205,14 @@ protected JavaMailSender createJavaMailSender() {
}
if (session != null) {
answer.setSession(session);
String host = session.getProperty("mail.smtp.host");
if (host != null && !host.isEmpty()) {
answer.setHost(host);
}
String port = session.getProperty("mail.smtp.port");
if (port != null && !port.isEmpty()) {
answer.setPort(Integer.parseInt(port));
}
} else {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
Expand Down Expand Up @@ -409,7 +417,7 @@ public Session getSession() {
/**
* Specifies the mail session that camel should use for all mail interactions. Useful in scenarios where
* mail sessions are created and managed by some other resource, such as a JavaEE container.
* If this is not specified, Camel automatically creates the mail session for you.
* When using a custom mail session, then the hostname and port from the mail session will be used (if configured on the session).
*/
public void setSession(Session session) {
this.session = session;
Expand Down
Expand Up @@ -139,9 +139,9 @@ public static class MailConfigurationNestedConfiguration {
/**
* Specifies the mail session that camel should use for all mail
* interactions. Useful in scenarios where mail sessions are created and
* managed by some other resource, such as a JavaEE container. If this
* is not specified, Camel automatically creates the mail session for
* you.
* managed by some other resource, such as a JavaEE container. When
* using a custom mail session, then the hostname and port from the mail
* session will be used (if configured on the session).
*/
private Session session;
/**
Expand Down Expand Up @@ -607,4 +607,4 @@ public void setMimeDecodeHeaders(Boolean mimeDecodeHeaders) {
this.mimeDecodeHeaders = mimeDecodeHeaders;
}
}
}
}

0 comments on commit 1c41a0f

Please sign in to comment.