You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2008/11/26 20:38:27 UTC

svn commit: r720959 - /servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java

Author: lhein
Date: Wed Nov 26 11:38:27 2008
New Revision: 720959

URL: http://svn.apache.org/viewvc?rev=720959&view=rev
Log:
Added a boolean flag to control the ignore behaviour of the MSG_TAG_TO property of the IN message. If using 2 endpoints - mail poller and mail sender - to just forward messages to another address you most likely ran into the issue, that the mail was always forwarded to the sender account again.
This behaviour is the result of the marshaling. The poller marshaling will put all mail properties into specific headers. If you now just forward this message to a mail sender, this sender will do a decision what TO address to use. The TO address in the message has always highest priority, so this will be used then. To disable this behaviour, you can now just set the flag ignoreTOProperty to true and then this property will be wiped out on message receiving.

Modified:
    servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java

Modified: servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java?rev=720959&r1=720958&r2=720959&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java Wed Nov 26 11:38:27 2008
@@ -54,6 +54,7 @@
     private String sender;
     private String receiver;
     private boolean debugMode;
+    private boolean ignoreTOProperty;
     private Map<String, String> customProperties;
 
     /*
@@ -118,6 +119,15 @@
                 // Define message
                 MimeMessage msg = new MimeMessage(session);
 
+                // check if ignore on TO property is enabled
+                if (isIgnoreTOProperty()) {
+                	// we should preset TO property from NMSG
+                	if (in.getProperty(AbstractMailMarshaler.MSG_TAG_TO) != null) {
+                		// delete the property
+                		in.setProperty(AbstractMailMarshaler.MSG_TAG_TO, null);
+                	}
+                }
+                
                 // let the marshaler to the conversion of message to mail
                 this.marshaler.convertJBIToMail(msg, exchange, in, this.sender, this.receiver);
 
@@ -184,6 +194,15 @@
                 // Define message
                 MimeMessage msg = new MimeMessage(session);
 
+                // check if ignore on TO property is enabled
+                if (isIgnoreTOProperty()) {
+                	// we should preset TO property from NMSG
+                	if (in.getProperty(AbstractMailMarshaler.MSG_TAG_TO) != null) {
+                		// delete the property
+                		in.setProperty(AbstractMailMarshaler.MAIL_TAG_TO, null);
+                	}
+                }
+                
                 // let the marshaler to the conversion of message to mail
                 this.marshaler.convertJBIToMail(msg, exchange, in, this.sender, this.receiver);
 
@@ -324,4 +343,18 @@
     public void setCustomProperties(Map<String, String> customProperties) {
         this.customProperties = customProperties;
     }
+
+    /**
+	 * @return the ignoreTOProperty
+	 */
+	public boolean isIgnoreTOProperty() {
+		return this.ignoreTOProperty;
+	}
+	
+	/**
+	 * @param ignoreTOProperty the ignoreTOProperty to set
+	 */
+	public void setIgnoreTOProperty(boolean ignoreTOProperty) {
+		this.ignoreTOProperty = ignoreTOProperty;
+	}
 }