You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by JackMigger <j....@web.de> on 2012/12/29 20:02:02 UTC

How to avoid sending message headers with mail component ?

Hi,

I'm querying a database with the iBatis component, then splitting the
resultlist into single messages.
These are sent each to email addresses from the result set - which works
fine and wonderfully easy with the camel mail component.

But when the receiver of that mail will inspect the details or properties of
the received mail, he'll see a lot of headers in the mail (e.g. my
resultlist or BCC header) that I don't want to be neither public nor sent.

Is it possible e.g. by certain parameters to send *nothing but the body* of
the camel message as plain text mail message ?

(I could remove some of my own headers before sending - but what about BCC ?
I'd like to filter out all unwanted headers by configuration to avoid
private data going public incidentially).  

Thanks for any help....



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-avoid-sending-message-headers-with-mail-component-tp5724719.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to avoid sending message headers with mail component ?

Posted by Claus Ibsen <cl...@gmail.com>.
Richard that was a good answer.

I added this as a FAQ as its a general question how to remove some/all headers
https://cwiki.apache.org/confluence/display/CAMEL/How+to+avoid+sending+some+or+all+message+headers

On Sat, Dec 29, 2012 at 8:52 PM, Richard Kettelerij
<ri...@gmail.com> wrote:
> This is a gotcha more people encounter. However it's very easy to solve. To
> remove all headers use a wildcard expression:
>
> from(...).removeHeaders("*").to("smtp://....")
>
> Similarly to remove all headers except some of your own (myheader1 and
> myheader2) use a wildcard with a vararg:
>
> from(...).removeHeaders("*", "myheader1", "myheader).to("smtp://....")
>
> Again to remove only Camel headers but no other transport headers:
>
> from(...).removeHeaders("Camel*").to("smtp://....")
>
> I think in your case removeHeaders("*") will suffice.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: How to avoid sending message headers with mail component ?

Posted by Richard Kettelerij <ri...@gmail.com>.
This is a gotcha more people encounter. However it's very easy to solve. To
remove all headers use a wildcard expression:

from(...).removeHeaders("*").to("smtp://....")

Similarly to remove all headers except some of your own (myheader1 and
myheader2) use a wildcard with a vararg:

from(...).removeHeaders("*", "myheader1", "myheader).to("smtp://....")

Again to remove only Camel headers but no other transport headers:

from(...).removeHeaders("Camel*").to("smtp://....")

I think in your case removeHeaders("*") will suffice.

Good luck!

Regards,
Richard

On Sat, Dec 29, 2012 at 8:02 PM, JackMigger <j....@web.de> wrote:

> Hi,
>
> I'm querying a database with the iBatis component, then splitting the
> resultlist into single messages.
> These are sent each to email addresses from the result set - which works
> fine and wonderfully easy with the camel mail component.
>
> But when the receiver of that mail will inspect the details or properties
> of
> the received mail, he'll see a lot of headers in the mail (e.g. my
> resultlist or BCC header) that I don't want to be neither public nor sent.
>
> Is it possible e.g. by certain parameters to send *nothing but the body* of
> the camel message as plain text mail message ?
>
> (I could remove some of my own headers before sending - but what about BCC
> ?
> I'd like to filter out all unwanted headers by configuration to avoid
> private data going public incidentially).
>
> Thanks for any help....
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-avoid-sending-message-headers-with-mail-component-tp5724719.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: How to avoid sending message headers with mail component ?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Just implement a custom strategy and then register that in the
registry, eg if spring then
<bean id="myCustomFilter" class=...">

And then configure the endpoint or component to use your filter.

?headerFilterStrategy=#myCustomFilter



On Wed, May 8, 2013 at 3:53 PM, AlanFoster <al...@alanfoster.me> wrote:
> Hi,
>
> Are there any examples of using a header filter strategy with the camel mail
> component?
>
> I can not see this option within the camel-mail page, not in the camel-mail
> MailConfiguration.java
>
> I assumed camel might be handle this filtering itself, but this I'm not sure
> this is true as the documentation suggests it is on a per-component basis
>
> - "An alternative is that [b]some[/b] of the Camel Components supports
> configuring a custom header filter strategy."
> http://camel.apache.org/how-to-avoid-sending-some-or-all-message-headers.html
>
> Would appreciate any guidance with this :)
> Cheers
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-avoid-sending-message-headers-with-mail-component-tp5724719p5732184.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: How to avoid sending message headers with mail component ?

Posted by AlanFoster <al...@alanfoster.me>.
Hi,

Are there any examples of using a header filter strategy with the camel mail
component?

I can not see this option within the camel-mail page, not in the camel-mail
MailConfiguration.java

I assumed camel might be handle this filtering itself, but this I'm not sure
this is true as the documentation suggests it is on a per-component basis 

- "An alternative is that [b]some[/b] of the Camel Components supports
configuring a custom header filter strategy."
http://camel.apache.org/how-to-avoid-sending-some-or-all-message-headers.html

Would appreciate any guidance with this :)
Cheers




--
View this message in context: http://camel.465427.n5.nabble.com/How-to-avoid-sending-message-headers-with-mail-component-tp5724719p5732184.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to avoid sending message headers with mail component ?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Oh another approach could be to use a custom header filter strategy on
the mail component / endpoint.
That will filter out all the headers, then only the body is being sent.



On Thu, Jan 3, 2013 at 9:27 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Tue, Jan 1, 2013 at 11:55 AM, JackMigger <j....@web.de> wrote:
>> Happy new year and thanks for the quick reply !
>>
>> But what happens in a (simplified) case like this:
>>
>> from("ibatis:selectUnprocessedAccounts?consumer.onConsume=consumeAccount")
>>   // returns a list of beans with partly private information
>>
>>   .split( ... )
>>   .removeHeaders("*")
>>    // set the message body from bean.text
>>   ...
>>   // set the headers to, cc, bcc from bean.email, bean.cc, etc...
>>   ...
>>    .to("smtp://...)
>>
>>   // bcc header is also sent in the mail (?)
>>
>>   // message/bean is now consumed, but any reference to the sql
>> consumeAccount statement (e.g. #id#)
>>   // has gone
>> .to("mock:results");
>>
>> As far as I understand, I have to filter out all but the further needed
>> headers (as "id").
>> Might there be a way to keep all camel message headers but configure that
>> *only the body* is mailed ?
>
> You can use the wire tap to spawn off a new message (sending a new exchange)
> where you only copy the body.
>
> See details at:
> http://camel.apache.org/wire-tap.html
>
> Something like
>     .wireTap("smtp:...", false, simple("${body}"))
>
>
>
>> (I'm aware that I could always write my own processor)
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/How-to-avoid-sending-message-headers-with-mail-component-tp5724719p5724752.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: How to avoid sending message headers with mail component ?

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jan 1, 2013 at 11:55 AM, JackMigger <j....@web.de> wrote:
> Happy new year and thanks for the quick reply !
>
> But what happens in a (simplified) case like this:
>
> from("ibatis:selectUnprocessedAccounts?consumer.onConsume=consumeAccount")
>   // returns a list of beans with partly private information
>
>   .split( ... )
>   .removeHeaders("*")
>    // set the message body from bean.text
>   ...
>   // set the headers to, cc, bcc from bean.email, bean.cc, etc...
>   ...
>    .to("smtp://...)
>
>   // bcc header is also sent in the mail (?)
>
>   // message/bean is now consumed, but any reference to the sql
> consumeAccount statement (e.g. #id#)
>   // has gone
> .to("mock:results");
>
> As far as I understand, I have to filter out all but the further needed
> headers (as "id").
> Might there be a way to keep all camel message headers but configure that
> *only the body* is mailed ?

You can use the wire tap to spawn off a new message (sending a new exchange)
where you only copy the body.

See details at:
http://camel.apache.org/wire-tap.html

Something like
    .wireTap("smtp:...", false, simple("${body}"))



> (I'm aware that I could always write my own processor)
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-avoid-sending-message-headers-with-mail-component-tp5724719p5724752.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: How to avoid sending message headers with mail component ?

Posted by JackMigger <j....@web.de>.
Happy new year and thanks for the quick reply !

But what happens in a (simplified) case like this:

from("ibatis:selectUnprocessedAccounts?consumer.onConsume=consumeAccount")
  // returns a list of beans with partly private information
  
  .split( ... )    
  .removeHeaders("*")
   // set the message body from bean.text
  ...
  // set the headers to, cc, bcc from bean.email, bean.cc, etc... 
  ...
   .to("smtp://...)

  // bcc header is also sent in the mail (?)  

  // message/bean is now consumed, but any reference to the sql
consumeAccount statement (e.g. #id#)
  // has gone 
.to("mock:results");

As far as I understand, I have to filter out all but the further needed
headers (as "id").
Might there be a way to keep all camel message headers but configure that
*only the body* is mailed ?
(I'm aware that I could always write my own processor)





--
View this message in context: http://camel.465427.n5.nabble.com/How-to-avoid-sending-message-headers-with-mail-component-tp5724719p5724752.html
Sent from the Camel - Users mailing list archive at Nabble.com.