You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Clive Haworth <cl...@vosatec.com> on 2010/06/23 15:19:42 UTC

[email] header clarification

I need some clarification on what is and isn't done to mail headers by 
commons email, both setting and getting.

RFC 822 forces all email headers to use characters in the US-ASCII range 
1 through 127. Headers not natively in US-ASCII need to be encoded using 
RFC 2047.

Additionally RFC 822 forces header lines longer than 998 characters to 
be folded.

Does commons email handle all this automatically in ALL cases, some 
cases (and if so which) or not at all?

Regards,
Clive Haworth


Re: [email] header clarification

Posted by Clive Haworth <cl...@vosatec.com>.

The main hurdle seems to be the design of the javax.mail headers 
structure but I don't think it is insurmountable...

All the setters / getters need to call one common setHeader() / 
getHeader() method which does the encoding / unencoding and folding / 
unfolding. We then need setRawHeader() / getRawHeader() methods to set / 
get raw data for higher level "structured header fields" as per RFC 822. 
It would be up to the application to provide specific lexical parsing of 
these headers. I've personally not ever come across them, but the RFC 
gives "address" as an example.

I'll have a go and let you know how things pan out.

On 24/06/2010 15:27, James Carman wrote:
> Well, if we can make things better (more correct), then we should try.
>   Do you already have code that does this stuff?  If so, create a JIRA
> with a patch and we can look into including it.  Contributions are
> *always* welcome, and I am not trying to say that in a snotty way.  It
> really does sound like you're onto something we can do to add value
> here (if we're not already).  If you need help creating the patch,
> just let me know.
>
> On Thu, Jun 24, 2010 at 8:30 AM, Clive Haworth
> <cl...@vosatec.com>  wrote:
>    
>>
>> Thanks for the pointer.
>>
>> I grabbed the source to MimeMessage.java and had a look. It seems that the
>> "standard" headers are US-ASCII encoded automatically when you use the
>> specific setter. For example setRecipient(), setReplyTo() etc.. However if
>> you use the generic setHeader() you have to do this yourself. The other
>> thing is that none of the methods do the automatic folding for long lines.
>>
>> Too complicated by half, if you ask me. This level of detail should be
>> handled by javax.mail and applications should not have to worry about it.
>> Worse is the javax.mail documentation: use the source Luke, as they say.
>>
>> On 23/06/2010 14:22, James Carman wrote:
>>      
>>> Commons Email is a "wrapper" around the JavaMail API.  I would imagine
>>> that the JavaMail provider(s) would be responsible for this.
>>>
>>> On Wed, Jun 23, 2010 at 9:19 AM, Clive Haworth
>>> <cl...@vosatec.com>    wrote:
>>>
>>>        
>>>> I need some clarification on what is and isn't done to mail headers by
>>>> commons email, both setting and getting.
>>>>
>>>> RFC 822 forces all email headers to use characters in the US-ASCII range
>>>> 1
>>>> through 127. Headers not natively in US-ASCII need to be encoded using
>>>> RFC
>>>> 2047.
>>>>
>>>> Additionally RFC 822 forces header lines longer than 998 characters to be
>>>> folded.
>>>>
>>>> Does commons email handle all this automatically in ALL cases, some cases
>>>> (and if so which) or not at all?
>>>>
>>>> Regards,
>>>> Clive Haworth
>>>>
>>>>
>>>>
>>>>          
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>>>        
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>    



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [email] header clarification

Posted by James Carman <ja...@carmanconsulting.com>.
Well, if we can make things better (more correct), then we should try.
 Do you already have code that does this stuff?  If so, create a JIRA
with a patch and we can look into including it.  Contributions are
*always* welcome, and I am not trying to say that in a snotty way.  It
really does sound like you're onto something we can do to add value
here (if we're not already).  If you need help creating the patch,
just let me know.

On Thu, Jun 24, 2010 at 8:30 AM, Clive Haworth
<cl...@vosatec.com> wrote:
>
>
> Thanks for the pointer.
>
> I grabbed the source to MimeMessage.java and had a look. It seems that the
> "standard" headers are US-ASCII encoded automatically when you use the
> specific setter. For example setRecipient(), setReplyTo() etc.. However if
> you use the generic setHeader() you have to do this yourself. The other
> thing is that none of the methods do the automatic folding for long lines.
>
> Too complicated by half, if you ask me. This level of detail should be
> handled by javax.mail and applications should not have to worry about it.
> Worse is the javax.mail documentation: use the source Luke, as they say.
>
> On 23/06/2010 14:22, James Carman wrote:
>>
>> Commons Email is a "wrapper" around the JavaMail API.  I would imagine
>> that the JavaMail provider(s) would be responsible for this.
>>
>> On Wed, Jun 23, 2010 at 9:19 AM, Clive Haworth
>> <cl...@vosatec.com>  wrote:
>>
>>>
>>> I need some clarification on what is and isn't done to mail headers by
>>> commons email, both setting and getting.
>>>
>>> RFC 822 forces all email headers to use characters in the US-ASCII range
>>> 1
>>> through 127. Headers not natively in US-ASCII need to be encoded using
>>> RFC
>>> 2047.
>>>
>>> Additionally RFC 822 forces header lines longer than 998 characters to be
>>> folded.
>>>
>>> Does commons email handle all this automatically in ALL cases, some cases
>>> (and if so which) or not at all?
>>>
>>> Regards,
>>> Clive Haworth
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [email] header clarification

Posted by Clive Haworth <cl...@vosatec.com>.

Thanks for the pointer.

I grabbed the source to MimeMessage.java and had a look. It seems that 
the "standard" headers are US-ASCII encoded automatically when you use 
the specific setter. For example setRecipient(), setReplyTo() etc.. 
However if you use the generic setHeader() you have to do this yourself. 
The other thing is that none of the methods do the automatic folding for 
long lines.

Too complicated by half, if you ask me. This level of detail should be 
handled by javax.mail and applications should not have to worry about 
it. Worse is the javax.mail documentation: use the source Luke, as they say.

On 23/06/2010 14:22, James Carman wrote:
> Commons Email is a "wrapper" around the JavaMail API.  I would imagine
> that the JavaMail provider(s) would be responsible for this.
>
> On Wed, Jun 23, 2010 at 9:19 AM, Clive Haworth
> <cl...@vosatec.com>  wrote:
>    
>> I need some clarification on what is and isn't done to mail headers by
>> commons email, both setting and getting.
>>
>> RFC 822 forces all email headers to use characters in the US-ASCII range 1
>> through 127. Headers not natively in US-ASCII need to be encoded using RFC
>> 2047.
>>
>> Additionally RFC 822 forces header lines longer than 998 characters to be
>> folded.
>>
>> Does commons email handle all this automatically in ALL cases, some cases
>> (and if so which) or not at all?
>>
>> Regards,
>> Clive Haworth
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>    



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [email] header clarification

Posted by James Carman <ja...@carmanconsulting.com>.
Commons Email is a "wrapper" around the JavaMail API.  I would imagine
that the JavaMail provider(s) would be responsible for this.

On Wed, Jun 23, 2010 at 9:19 AM, Clive Haworth
<cl...@vosatec.com> wrote:
> I need some clarification on what is and isn't done to mail headers by
> commons email, both setting and getting.
>
> RFC 822 forces all email headers to use characters in the US-ASCII range 1
> through 127. Headers not natively in US-ASCII need to be encoded using RFC
> 2047.
>
> Additionally RFC 822 forces header lines longer than 998 characters to be
> folded.
>
> Does commons email handle all this automatically in ALL cases, some cases
> (and if so which) or not at all?
>
> Regards,
> Clive Haworth
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org