Ivan,

I can't see a real difference. The only thing is that you do:
    msg.setProperty(MSG_TAG_XXXX, YYYY);        

It seems you defines that constant in your own class? Be sure to use one of
the below:
    msg.setProperty(AbstractMailMarshaler.MSG_TAG_FROM,
"[EMAIL PROTECTED]");
  or 
    msg.setProperty("org.apache.servicemix.mail.from",
"[EMAIL PROTECTED]");


Regards
Lars





ivan-50 wrote:
> 
> Hi Lars!
> 
> My code looks like :
> 
> <<< SomeClass implements MessageExchangeListener;
> 
> ServiceMixClient client = new ServiceMixClientFacade(context);                
>         
> EndpointResolver tmpER = client.createResolverForService(destQname);
> InOnly io = client.createInOnlyExchange(tmpER);
> NormalizedMessage msg = io.getInMessage();    
> msg.setProperty(MSG_TAG_XXXX, YYYY);  
> ...
> client.send(io);
> 
>  >>>
> 
> 
> What is principal difference between my code and yours?
> 
> Thanks,
> Truly yours,
> Ivan Pryvalov.
> 
> 
> Lars Heinemann пишет:
>> Ivan,
>> 
>> it should work if you put the property to the normalized message...
>> 
>> For example:
>> 
>> MessageExchange me = ....;
>> NormalizedMessage nmsg = me.createMessage();
>> 
>> nmsg.setProperty(AbstractMailMarshaler.MSG_TAG_FROM,
>> "[EMAIL PROTECTED]");
>> 
>> me.setMessage(nmsg, "in");
>> getChannel().send(me);
>> 
>> The property has to be set on the In-Message...not on the message
>> exchange.
>> 
>> Regards
>> Lars
>> 
>> 
>> 
>> Am Montag 13 Oktober 2008 16:48:33 schrieb ivan:
>>> Hi Lars!
>>>
>>> Ok, I just tried to set sender via NM, but I can not do it.
>>>
>>> <<<
>>> if there is a preconfigured sender for the endpoint from xbean.xml, it
>>> will be used
>>> else if MSG_TAG_FROM is defined in the message properties, then it will
>>> be used
>>> else the method getDefaultSender() of the marshaler is invoked
>>>
>>>
>>> I wanted to set tag "From" via second way. But it my tests it didn't
>>> work. I back to first way :)
>>>
>>>
>>> Truly yours,
>>> Ivan Pryvalov.
>>>
>>> Lars Heinemann пишет:
>>>> Ivan,
>>>>
>>>> I don't understand your question?
>>>>
>>>> Looking at the code...
>>>>
>>>> if (this.sender == null) {
>>>>     this.sender = this.marshaler != null
>>>>                 ? this.marshaler.getDefaultSenderForOutgoingMails() :
>>>> AbstractMailMarshaler.DEFAULT_SENDER;
>>>>         }
>>>>
>>>> Given the situation, a marshaler returns NULL on method
>>>> getDefaultSenderForOutgoingMails() you would run into a NPE without
>>>> this
>>>> check. So this check is absolute needed here.
>>>>
>>>> Regards
>>>> Lars
>>>>
>>>> Am Montag 13 Oktober 2008 12:56:41 schrieb ivan:
>>>>> Hi Lars!
>>>>>
>>>>> All shown code has check on Null:
>>>>>
>>>>> <<<
>>>>> if (from != null) {
>>>>>    mimeMessage.setFrom(from);
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> As far as I understood, anyway "from" is set either from "this.sender"
>>>>> or "this.marshaler.getDefaultSenderForOutgoingMails()".
>>>>> So, we can not get situation (from==null). It is correct?
>>>>>
>>>>> Ivan Pryvalov.
>>>>>
>>>>> Lars Heinemann пишет:
>>>>>> Ivan,
>>>>>>
>>>>>> you only look at one aspect of the logic.
>>>>>> Please have a look at the DefaultMailMarshaler class.
>>>>>>
>>>>>>     protected void fillMailHeaders(MimeMessage mimeMessage,
>>>>>> MessageExchange exchange,
>>>>>>                                    NormalizedMessage nmsg, String
>>>>>> configuredSender, String configuredReceiver)
>>>>>>         throws Exception {
>>>>>>
>>>>>>         ...
>>>>>>
>>>>>>         // fill the "From" field of the mail
>>>>>>         if (configuredSender != null &&
>>>>>> configuredSender.trim().length()
>>>>>>
>>>>>>> 0) { // if sender is configured through xbean then use it Address
>>>>>>> from
>>>>>> = InternetAddress.parse(configuredSender)[0]; if (from != null) {
>>>>>>                 mimeMessage.setFrom(from);
>>>>>>             }
>>>>>>         } else if
>>>>>> (nmsg.getProperty(AbstractMailMarshaler.MSG_TAG_FROM)
>>>>>> != null) {
>>>>>>             // use the delivered From field from the message
>>>>>>             Address from =
>>>>>> InternetAddress.parse(nmsg.getProperty(AbstractMailMarshaler.MSG_TAG_FR
>>>>>> OM ) .toString())[0];
>>>>>>             if (from != null) {
>>>>>>                 mimeMessage.setFrom(from);
>>>>>>             }
>>>>>>         } else {
>>>>>>             // there was no From field delivered, so use the default
>>>>>> sender Address from =
>>>>>> InternetAddress.parse(getDefaultSenderForOutgoingMails())[0];
>>>>>>             if (from != null) {
>>>>>>                 mimeMessage.setFrom(from);
>>>>>>             }
>>>>>>         }
>>>>>>
>>>>>>         ...
>>>>>>
>>>>>>
>>>>>> I hope this makes it more clear to you. If you write your own
>>>>>> marshaler, then you are also responsible for filling the mail
>>>>>> properties correctly. When using the default marshaler, all should
>>>>>> work
>>>>>> fine if you did it correct.
>>>>>>
>>>>>> Regards
>>>>>> Lars
>>>>>>
>>>>>> Am Freitag 10 Oktober 2008 15:30:05 schrieb ivan:
>>>>>>> Hi!
>>>>>>>
>>>>>>> I read at http://servicemix.apache.org/servicemix-mail.html:
>>>>>>>
>>>>>>> <<<
>>>>>>> How is the sender determined?
>>>>>>>
>>>>>>> if there is a preconfigured sender for the endpoint from xbean.xml,
>>>>>>> it
>>>>>>> will be used
>>>>>>> else if MSG_TAG_FROM is defined in the message properties, then it
>>>>>>> will be used
>>>>>>> else the method getDefaultSender() of the marshaler is invoked
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Also I looked at the source (I downloaded it some month ago from
>>>>>>> 3.3-SNAPSHOT):
>>>>>>>
>>>>>>> <<< MailSenderEndpoint.java
>>>>>>>
>>>>>>>      public void validate() throws DeploymentException {
>>>>>>>          super.validate();
>>>>>>>
>>>>>>>          if (this.config == null || this.connection == null) {
>>>>>>>              throw new DeploymentException("No valid connection uri
>>>>>>> provided.");
>>>>>>>          }
>>>>>>>          if (this.sender == null) {
>>>>>>>              this.sender = this.marshaler != null
>>>>>>>                  ? this.marshaler.getDefaultSenderForOutgoingMails()
>>>>>>> :
>>>>>>> AbstractMailMarshaler.DEFAULT_SENDER;
>>>>>>>          }
>>>>>>>      }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> So, it seems, there is no way to configure "sender" header for
>>>>>>> e-mail
>>>>>>> via MSG_TAG_FROM.
>>>>>>>
>>>>>>> Am I right? Or maybe it is already fixed?
>>>>>>>
>>>>>>> Truly yours,
>>>>>>> Ivan Pryvalov.
>> 
>> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Servicemix-mail-and-sender-tp19918413p19959445.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to