You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/01/23 19:09:04 UTC
(camel) 01/01: CAMEL-22900: camel-mail - Add mail.smtps.xxx headers for sending with SMTPS emails
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch smtps
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 02171856ff3108653bd1d3795fa0225d38eda1e3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jan 23 20:08:46 2026 +0100
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..0812f29dfb85 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 smpt 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;