It looks like camel-mail cannot handle unicode chars in subject header? I
have something like below and subject does not appear correctly in mail
client -

    @Test
    public void testMailSubjectWithUnicode() throws Exception {
        Mailbox.clearAll();

        String body = "Hello Camel Riders!";
        String subject = "My Camel \u2122";     

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(1);
        //mock.expectedHeaderReceived("subject", "My_Camel_=AA");
        mock.expectedBodiesReceived(body);

        template.sendBodyAndHeader("direct:a", body, "subject", subject);

        mock.assertIsSatisfied();

        assertFalse("Should not have attachements",
mock.getExchanges().get(0).getIn().hasAttachments());
    }

I tried looking into fix but I am exactly not sure if I have the right fix.
It looks like in MailBinding class subject is not added using correct method
-

mimeMessage.setHeader(headerName, asString(exchange, headerValue));

but should instead be? 

mimeMessage.setSubject(asString(exchange, headerValue));

Looking at JavaDoc and source it looks like setSubject() method will
actually find right encoder and do the encoding for subject. I made changes
to mailBinding and it indeed fixed it but looks like it uses platform
specific encoding so was confused if that is right approach, any ideas?

Also, platform specific encoding may make unit testing difficult?


Thanks!






-- 
View this message in context: 
http://old.nabble.com/Camel-Mail%3A-Subject-cannot-handle-unicode-chars--tp28700124p28700124.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to