[
https://issues.apache.org/jira/browse/CAMEL-12119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16319111#comment-16319111
]
ASF GitHub Bot commented on CAMEL-12119:
----------------------------------------
sijskes closed pull request #2172: fix for
https://issues.apache.org/jira/browse/CAMEL-12119 [CAMEL-12119]
URL: https://github.com/apache/camel/pull/2172
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-mail/src/main/java/org/apache/camel/component/mail/DefaultJavaMailSender.java
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/DefaultJavaMailSender.java
index 9198ef1f5d4..c73eb530026 100644
---
a/components/camel-mail/src/main/java/org/apache/camel/component/mail/DefaultJavaMailSender.java
+++
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/DefaultJavaMailSender.java
@@ -22,8 +22,8 @@
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -121,7 +121,18 @@ public void send(MimeMessage mimeMessage) throws
MessagingException {
mimeMessage.setHeader("Message-ID", messageId);
}
LOG.debug("Sending MimeMessage: {} using host: {}", mimeMessage,
host);
- transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
+
+ String[] recipients = mimeMessage.getHeader( "X-Recipient" );
+
+ if( recipients == null || recipients.length == 0 ) {
+ transport.sendMessage( mimeMessage,
mimeMessage.getAllRecipients() );
+ } else {
+ InternetAddress ra[] = new InternetAddress[recipients.length];
+ for( int i = 0; i < recipients.length; i++ ) {
+ ra[i] = new InternetAddress( recipients[i], true );
+ }
+ transport.sendMessage( mimeMessage, ra );
+ }
} finally {
try {
transport.close();
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> allow override of smtp recipients
> ---------------------------------
>
> Key: CAMEL-12119
> URL: https://issues.apache.org/jira/browse/CAMEL-12119
> Project: Camel
> Issue Type: Improvement
> Components: camel-mail
> Affects Versions: 2.20.1
> Reporter: Simon IJskes
> Priority: Minor
> Attachments: new.txt
>
>
> Currently there is no way to override recipients for a SMTP email.
> In order to forward an email to a secundairy address not specified in the
> content-addressing, aka 'a redirect', a header called 'X-recipient' could be
> used to override the recipients of the email.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)