1Mail::Message::Field::FUuslelr(3C)ontributed Perl DocumeMnatialt:i:oMnessage::Field::Full(3)
2
3
4
6 Mail::Message::Field::Full - construct one smart line in a message
7 header
8
10 Mail::Message::Field::Full
11 is a Mail::Message::Field
12 is a Mail::Reporter
13
14 Mail::Message::Field::Full is extended by
15 Mail::Message::Field::Structured
16 Mail::Message::Field::Unstructured
17
19 !! UNDER CONSTRUCTION
20 !! The details of this module are NOT FINISHED yet
21 !! Most parts are already usable, however. With care!
22
23 # Getting to understand the complexity of a header field ...
24
25 my $fast = $msg->head->get('subject');
26 my $full = Mail::Message::Field::Full->from($fast);
27
28 my $full = $msg->head->get('subject')->study; # same
29 my $full = $msg->head->study('subject'); # same
30 my $full = $msg->get('subject'); # same
31
32 # ... or build a complex header field yourself
33
34 my $f = Mail::Message::Field::Full->new('To');
35 my $f = Mail::Message::Field::Full->new('Subject: hi!');
36 my $f = Mail::Message::Field::Full->new(Subject => 'hi!');
37
39 This is the full implementation of a header field: it has full
40 understanding of all predefined header fields. These objects will be
41 quite slow, because header fields can be very complex. Of course, this
42 class delivers the optimal result, but for a quite large penalty in
43 performance and memory consumption. Are you willing to accept?
44
45 This class supports the common header description from RFC2822
46 (formerly RFC822), the extensions with respect to character set
47 encodings as specified in RFC2047, and the extensions on language
48 specification and long parameter wrapping from RFC2231. If you do not
49 need the latter two, then the Mail::Message::Field::Fast and
50 Mail::Message::Field::Flex are enough for your application.
51
53 overload: ""
54 See "OVERLOADED" in Mail::Message::Field
55
56 overload: +0
57 See "OVERLOADED" in Mail::Message::Field
58
59 overload: <=>
60 See "OVERLOADED" in Mail::Message::Field
61
62 overload: bool
63 See "OVERLOADED" in Mail::Message::Field
64
65 overload: cmp
66 See "OVERLOADED" in Mail::Message::Field
67
68 overload: stringification
69 In string context, the decoded body is returned, as if
70 decodedBody() would have been called.
71
73 Constructors
74 $obj->clone
75 See "Constructors" in Mail::Message::Field
76
77 Mail::Message::Field::Full->from(FIELD, OPTIONS)
78 Convert any FIELD (a Mail::Message::Field object) into a new
79 Mail::Message::Field::Full object. This conversion is done the
80 hard way: the string which is produced by the original object is
81 parsed again. Usually, the string which is parsed is exactly the
82 line (or lines) as found in the original input source, which is a
83 good thing because Full fields are much more carefull with the
84 actual content.
85
86 OPTIONS are passed to the constructor (see new()). In any case,
87 some extensions of this Full field class is returned. It depends
88 on which field is created what kind of class we get.
89
90 example:
91
92 my $fast = $msg->head->get('subject');
93 my $full = Mail::Message::Field::Full->from($fast);
94
95 my $full = $msg->head->get('subject')->study; # same
96 my $full = $msg->head->study('subject'); # same
97 my $full = $msg->get('subject'); # same
98
99 Mail::Message::Field::Full->new(DATA)
100 Creating a new field object the correct way is a lot of work,
101 because there is so much freedom in the RFCs, but at the same time
102 so many restrictions. Most fields are implemented, but if you have
103 your own field (and do no want to contribute it to MailBox), then
104 simply call new on your own package.
105
106 You have the choice to instantiate the object as string or in
107 prepared parts:
108
109 · new LINE, OPTIONS
110
111 Pass a LINE as it could be found in a file: a (possibly folded)
112 line which is terminated by a new-line.
113
114 · new NAME, [BODY], OPTIONS
115
116 A set of values which shape the line.
117
118 The NAME is a wellformed header name (you may use wellformedName())
119 to be sure about the casing. The BODY is a string, one object, or
120 an ref-array of objects. In case of objects, they must fit to the
121 constructor of the field: the types which are accepted may differ.
122 The optional ATTRIBUTE list contains
123 Mail::Message::Field::Attribute objects. Finally, there are some
124 OPTIONS.
125
126 -Option --Defined in --Default
127 charset undef
128 encoding 'q'
129 force false
130 language undef
131 log Mail::Reporter 'WARNINGS'
132 trace Mail::Reporter 'WARNINGS'
133
134 charset => STRING
135 The body is specified in utf8, and must become 7-bits ascii to be
136 transmited. Specify a charset to which the multi-byte utf8 is
137 converted before it gets encoded. See encode(), which does the
138 job.
139
140 encoding => 'q'|'Q'|'b'|'B'
141 Non-ascii characters are encoded using Quoted-Printable ('q' or
142 'Q') or Base64 ('b' or 'B') encoding.
143
144 force => BOOLEAN
145 Enforce encoding in the specified charset, even when it is not
146 needed because the body does not contain any non-ascii
147 characters.
148
149 language => STRING
150 The language used can be specified, however is rarely used my
151 mail clients.
152
153 log => LEVEL
154 trace => LEVEL
155
156 example:
157
158 my $s = Mail::Message::Field::Full->new('Subject: Hello World');
159 my $s = Mail::Message::Field::Full->new('Subject', 'Hello World');
160
161 my @attrs = (Mail::Message::Field::Attribute->new(...), ...);
162 my @options = (extra => 'the color blue');
163 my $t = Mail::Message::Field::Full->new(To => \@addrs, @attrs, @options);
164
165 The field
166 $obj->isStructured
167 Mail::Message::Field::Full->isStructured
168
169 See "The field" in Mail::Message::Field
170
171 $obj->length
172 See "The field" in Mail::Message::Field
173
174 $obj->nrLines
175 See "The field" in Mail::Message::Field
176
177 $obj->print([FILEHANDLE])
178 See "The field" in Mail::Message::Field
179
180 $obj->size
181 See "The field" in Mail::Message::Field
182
183 $obj->string([WRAP])
184 See "The field" in Mail::Message::Field
185
186 $obj->toDisclose
187 See "The field" in Mail::Message::Field
188
189 Access to the name
190 $obj->Name
191 See "Access to the name" in Mail::Message::Field
192
193 $obj->name
194 See "Access to the name" in Mail::Message::Field
195
196 $obj->wellformedName([STRING])
197 See "Access to the name" in Mail::Message::Field
198
199 Access to the body
200 $obj->body
201 See "Access to the body" in Mail::Message::Field
202
203 $obj->decodedBody(OPTIONS)
204 Returns the unfolded body of the field, where encodings are
205 resolved. The returned line will still contain comments and such.
206 The OPTIONS are passed to the decoder, see decode().
207
208 BE WARNED: if the field is a structured field, the content may
209 change syntax, because of encapsulated special characters. By
210 default, the body is decoded as text, which results in a small
211 difference within comments as well (read the RFC).
212
213 $obj->folded
214 See "Access to the body" in Mail::Message::Field
215
216 $obj->foldedBody([BODY])
217 See "Access to the body" in Mail::Message::Field
218
219 $obj->stripCFWS([STRING])
220 Mail::Message::Field::Full->stripCFWS([STRING])
221
222 See "Access to the body" in Mail::Message::Field
223
224 $obj->unfoldedBody([BODY, [WRAP]])
225 See "Access to the body" in Mail::Message::Field
226
227 Access to the content
228 $obj->addresses
229 See "Access to the content" in Mail::Message::Field
230
231 $obj->attribute(NAME [, VALUE])
232 See "Access to the content" in Mail::Message::Field
233
234 $obj->attributes
235 See "Access to the content" in Mail::Message::Field
236
237 $obj->beautify
238 For structured header fields, this removes the original encoding of
239 the field's body (the format as it was offered to parse()),
240 therefore the next request for the field will have to re-produce
241 the read data clean and nice. For unstructured bodies, this method
242 doesn't do a thing.
243
244 $obj->comment([STRING])
245 See "Access to the content" in Mail::Message::Field
246
247 $obj->createComment(STRING, OPTIONS)
248 Mail::Message::Field::Full->createComment(STRING, OPTIONS)
249
250 Create a comment to become part in a field. Comments are
251 automatically included within parenthesis. Matching pairs of
252 parenthesis are permitted within the STRING. When a non-matching
253 parenthesis are used, it is only permitted with an escape (a
254 backslash) in front of them. These backslashes will be added
255 automatically if needed (don't worry!). Backslashes will stay,
256 except at the end, where it will be doubled.
257
258 The OPTIONS are "charset", "language", and "encoding" as always.
259 The created comment is returned.
260
261 $obj->createPhrase(STRING, OPTIONS)
262 Mail::Message::Field::Full->createPhrase(STRING, OPTIONS)
263
264 A phrase is a text which plays a well defined role. This is the
265 main difference with comments, which have do specified meaning.
266 Some special characters in the phrase will cause it to be
267 surrounded with double quotes: do not specify them yourself.
268
269 The OPTIONS are "charset", "language", and "encoding", as always.
270
271 $obj->study
272 See "Access to the content" in Mail::Message::Field
273
274 $obj->toDate([TIME])
275 Mail::Message::Field::Full->toDate([TIME])
276
277 See "Access to the content" in Mail::Message::Field
278
279 $obj->toInt
280 See "Access to the content" in Mail::Message::Field
281
282 Other methods
283 $obj->dateToTimestamp(STRING)
284 Mail::Message::Field::Full->dateToTimestamp(STRING)
285
286 See "Other methods" in Mail::Message::Field
287
288 Internals
289 $obj->consume(LINE | (NAME,BODY|OBJECTS))
290 See "Internals" in Mail::Message::Field
291
292 $obj->decode(STRING, OPTIONS)
293 Mail::Message::Field::Full->decode(STRING, OPTIONS)
294
295 Decode field encoded STRING to an utf8 string. The input STRING is
296 part of a header field, and as such, may contain encoded words in
297 "=?...?.?...?=" format defined by RFC2047. The STRING may contain
298 multiple encoded parts, maybe using different character sets.
299
300 Be warned: you MUST first interpret the field into parts, like
301 phrases and comments, and then decode each part separately,
302 otherwise the decoded text may interfere with your markup
303 characters.
304
305 Be warned: language information, which is defined in RFC2231, is
306 ignored.
307
308 Encodings with unknown charsets are left untouched [requires
309 v2.085, otherwise croaked]. Unknown characters within an charset
310 are replaced by a '?'.
311
312 -Option --Default
313 is_text 1
314
315 is_text => BOOLEAN
316 Encoding on text is slightly more complicated than encoding
317 structured data, because it contains blanks. Visible blanks have
318 to be ignored between two encoded words in the text, but not when
319 an encoded word follows or preceeds an unencoded word. Phrases
320 and comments are texts.
321
322 example:
323
324 print Mail::Message::Field::Full->decode('=?iso-8859-1?Q?J=F8rgen?=');
325 # prints JE<0slash>rgen
326
327 $obj->defaultWrapLength([LENGTH])
328 See "Internals" in Mail::Message::Field
329
330 $obj->encode(STRING, OPTIONS)
331 Encode the (possibly utf8 encoded) STRING to a string which is
332 acceptable to the RFC2047 definition of a header: only containing
333 us-ascii characters.
334
335 -Option --Default
336 charset 'us-ascii'
337 encoding 'q'
338 force <flase>
339 language undef
340
341 charset => STRING
342 STRING is an utf8 string which has to be translated into any
343 byte-wise character set for transport, because MIME-headers can
344 only contain ascii characters.
345
346 encoding => 'q'|'Q'|'b'|'B'
347 The character encoding to be used. With "q" or "Q", quoted-
348 printable encoding will be used. With "b " or "B ", base64
349 encoding will be taken.
350
351 force => BOOLEAN
352 Encode the string, even when it only contains us-ascii
353 characters. By default, this is off because it decreases
354 readibility of the produced header fields.
355
356 language => STRING
357 RFC2231 defines how to specify language encodings in encoded
358 words. The STRING is a strandard iso language name.
359
360 $obj->fold(NAME, BODY, [MAXCHARS])
361 Mail::Message::Field::Full->fold(NAME, BODY, [MAXCHARS])
362
363 See "Internals" in Mail::Message::Field
364
365 $obj->setWrapLength([LENGTH])
366 See "Internals" in Mail::Message::Field
367
368 $obj->stringifyData(STRING|ARRAY|OBJECTS)
369 See "Internals" in Mail::Message::Field
370
371 $obj->unfold(STRING)
372 See "Internals" in Mail::Message::Field
373
374 Parsing
375 $obj->consumeComment(STRING)
376 Mail::Message::Field::Full->consumeComment(STRING)
377
378 Try to read a comment from the STRING. When successful, the
379 comment without encapsulation parenthesis is returned, together
380 with the rest of the string.
381
382 $obj->consumeDotAtom(STRING)
383 Returns three elemens: the atom-text, the rest string, and the
384 concatenated comments. Both atom and comments can be undef.
385
386 $obj->consumePhrase(STRING)
387 Mail::Message::Field::Full->consumePhrase(STRING)
388
389 Take the STRING, and try to strip-off a valid phrase. In the
390 obsolete phrase syntax, any sequence of words is accepted as phrase
391 (as long as certain special characters are not used). RFC2882 is
392 stricter: only one word or a quoted string is allowed. As always,
393 the obsolete syntax is accepted, and the new syntax is produced.
394
395 This method returns two elements: the phrase (or undef) followed by
396 the resulting string. The phrase will be removed from the optional
397 quotes. Be warned that "" will return an empty, valid phrase.
398
399 example:
400
401 my ($phrase, $rest) = $field->consumePhrase( q["hi!" <sales@example.com>] );
402
403 $obj->parse(STRING)
404 Get the detailed information from the STRING, and store the data
405 found in the field object. The accepted input is very field type
406 dependent. Unstructured fields do no parsing whatsoever.
407
408 $obj->produceBody
409 Produce the text for the field, based on the information stored
410 within the field object.
411
412 Usually, you wish the exact same line as was found in the input
413 source of a message. But when you have created a field yourself,
414 it should get formatted. You may call beautify() on a preformatted
415 field to enforce a call to this method when the field is needed
416 later.
417
418 Error handling
419 $obj->AUTOLOAD
420 See "Error handling" in Mail::Reporter
421
422 $obj->addReport(OBJECT)
423 See "Error handling" in Mail::Reporter
424
425 $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
426 Mail::Message::Field::Full->defaultTrace([LEVEL]|[LOGLEVEL,
427 TRACELEVEL]|[LEVEL, CALLBACK])
428
429 See "Error handling" in Mail::Reporter
430
431 $obj->errors
432 See "Error handling" in Mail::Reporter
433
434 $obj->log([LEVEL [,STRINGS]])
435 Mail::Message::Field::Full->log([LEVEL [,STRINGS]])
436
437 See "Error handling" in Mail::Reporter
438
439 $obj->logPriority(LEVEL)
440 Mail::Message::Field::Full->logPriority(LEVEL)
441
442 See "Error handling" in Mail::Reporter
443
444 $obj->logSettings
445 See "Error handling" in Mail::Reporter
446
447 $obj->notImplemented
448 See "Error handling" in Mail::Reporter
449
450 $obj->report([LEVEL])
451 See "Error handling" in Mail::Reporter
452
453 $obj->reportAll([LEVEL])
454 See "Error handling" in Mail::Reporter
455
456 $obj->trace([LEVEL])
457 See "Error handling" in Mail::Reporter
458
459 $obj->warnings
460 See "Error handling" in Mail::Reporter
461
462 Cleanup
463 $obj->DESTROY
464 See "Cleanup" in Mail::Reporter
465
466 $obj->inGlobalDestruction
467 See "Cleanup" in Mail::Reporter
468
470 Warning: Field content is not numerical: $content
471 The numeric value of a field is requested (for instance the "Lines"
472 or "Content-Length" fields should be numerical), however the data
473 contains weird characters.
474
475 Warning: Illegal character in charset '$charset'
476 The field is created with an utf8 string which only contains data
477 from the specified character set. However, that character set can
478 never be a valid name because it contains characters which are not
479 permitted.
480
481 Warning: Illegal character in field name $name
482 A new field is being created which does contain characters not
483 permitted by the RFCs. Using this field in messages may break
484 other e-mail clients or transfer agents, and therefore mutulate or
485 extinguish your message.
486
487 Warning: Illegal character in language '$lang'
488 The field is created with data which is specified to be in a
489 certain language, however, the name of the language cannot be
490 valid: it contains characters which are not permitted by the RFCs.
491
492 Warning: Illegal encoding '$encoding', used 'q'
493 The RFCs only permit base64 ("b " or "B ") or quoted-printable ("q"
494 or "Q") encoding. Other than these four options are illegal.
495
496 Error: Package $package does not implement $method.
497 Fatal error: the specific package (or one of its superclasses) does
498 not implement this method where it should. This message means that
499 some other related classes do implement this method however the
500 class at hand does not. Probably you should investigate this and
501 probably inform the author of the package.
502
504 This module is part of Mail-Box distribution version 2.097, built on
505 January 26, 2011. Website: http://perl.overmeer.net/mailbox/
506
508 Copyrights 2001-2011 by Mark Overmeer. For other contributors see
509 ChangeLog.
510
511 This program is free software; you can redistribute it and/or modify it
512 under the same terms as Perl itself. See
513 http://www.perl.com/perl/misc/Artistic.html
514
515
516
517perl v5.12.3 2011-01-26 Mail::Message::Field::Full(3)