This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new b1728757b055 CAMEL-22900: camel-mail - Add mail.smtps.xxx headers for
sending with… (#21004)
b1728757b055 is described below
commit b1728757b05566eeef035de3432d4db8806f420f
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Jan 24 08:08:03 2026 +0100
CAMEL-22900: camel-mail - Add mail.smtps.xxx headers for sending with…
(#21004)
* CAMEL-22900: camel-mail - Add mail.smtps.xxx headers for sending with
SMTPS emails
---
.../org/apache/camel/component/mail/MailConfiguration.java | 6 ++++++
.../java/org/apache/camel/component/mail/MailProducer.java | 12 +++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git
a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
index 36fc2f868e7d..1036ea4c9009 100644
---
a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
+++
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
@@ -239,10 +239,16 @@ public class MailConfiguration implements Cloneable {
if (session != null) {
answer.setSession(session);
String hostPropertyValue = session.getProperty("mail.smtp.host");
+ if (hostPropertyValue == null || hostPropertyValue.isEmpty()) {
+ hostPropertyValue = session.getProperty("mail.smtps.host");
+ }
if (hostPropertyValue != null && !hostPropertyValue.isEmpty()) {
answer.setHost(hostPropertyValue);
}
String portPropertyValue = session.getProperty("mail.smtp.port");
+ if (portPropertyValue == null || portPropertyValue.isEmpty()) {
+ portPropertyValue = session.getProperty("mail.smtps.port");
+ }
if (portPropertyValue != null && !portPropertyValue.isEmpty()) {
answer.setPort(Integer.parseInt(portPropertyValue));
}
diff --git
a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
index 417bf3a09614..f0557eb6a543 100644
---
a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
+++
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
@@ -87,8 +87,13 @@ public class MailProducer extends DefaultAsyncProducer {
}
protected JavaMailSender getSender(Exchange exchange) {
- // do we have special headers
- Map<String, Object> additional =
URISupport.extractProperties(exchange.getMessage().getHeaders(), "mail.smtp.");
+ // do we have special headers (try both smtp and smtps)
+ String prefix = "mail.smtp.";
+ Map<String, Object> additional =
URISupport.extractProperties(exchange.getMessage().getHeaders(), prefix);
+ if (additional.isEmpty()) {
+ prefix = "mail.smtps.";
+ additional =
URISupport.extractProperties(exchange.getMessage().getHeaders(), prefix);
+ }
if (additional.isEmpty()) {
// no then use default sender
LOG.trace("Using default JavaMailSender");
@@ -98,10 +103,11 @@ public class MailProducer extends DefaultAsyncProducer {
LOG.debug("Creating new JavaMailSender to include additional {}
java mail properties", additional.size());
JavaMailSender customSender
=
getEndpoint().getConfiguration().createJavaMailSender(getEndpoint().getCamelContext());
+ final String scheme = prefix;
additional.forEach((k, v) -> {
if (v != null) {
// add with prefix so we dont loose that
- customSender.addAdditionalJavaMailProperty("mail.smtp." +
k, v.toString());
+ customSender.addAdditionalJavaMailProperty(scheme + k,
v.toString());
}
});
return customSender;