How to avoid sending message headers with mail component ?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to avoid sending message headers with mail component ?

JackMigger
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....
Reply | Threaded
Open this post in threaded view
|

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

Richard Kettelerij
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 <[hidden email]> 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.
>
Reply | Threaded
Open this post in threaded view
|

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

Claus Ibsen-2
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
<[hidden email]> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

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

JackMigger
In reply to this post by JackMigger
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)

Reply | Threaded
Open this post in threaded view
|

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

Claus Ibsen-2
On Tue, Jan 1, 2013 at 11:55 AM, JackMigger <[hidden email]> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

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

Claus Ibsen-2
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 <[hidden email]> wrote:

> On Tue, Jan 1, 2013 at 11:55 AM, JackMigger <[hidden email]> 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: [hidden email]
> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

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

AlanFoster
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
Reply | Threaded
Open this post in threaded view
|

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

Claus Ibsen-2
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 <[hidden email]> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen