File: Forward.pod

package info (click to toggle)
libmail-box-perl 2.068-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,576 kB
  • ctags: 1,493
  • sloc: perl: 22,358; makefile: 49
file content (502 lines) | stat: -rw-r--r-- 15,031 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502

=head1 NAME

Mail::Message::Construct::Forward - forwarding a Mail::Message



=head1 SYNOPSIS

 my Mail::Message $forward = $message->forward(To => 'you');
 $forward->send;


=head1 DESCRIPTION

Complex functionality on L<Mail::Message|Mail::Message> objects is implemented in
different files which are autoloaded.  This file implements the
functionality related to creating forwarded messages.



=head1 METHODS


=head2 Constructing a message


$obj-E<gt>B<forward>(OPTIONS)

=over 4

Forward the content of this message.  The body of the message to be forwarded
is encapsulated in some accompanying text (if you have no wish for that, than
C<bounce> is your choice).  A L<Mail::Message|Mail::Message> object is returned on success.

You may forward a whole message, but also message parts.
You may wish to overrule some of the default header settings for the
reply immediately, or you may do that later with C<set> on the header.

When a multi-part body is encountered, and the message is included to
ATTACH, the parts which look like signatures will be removed.  If only
one message remains, it will be the added as single attachment, otherwise
a nested multipart will be the result.  The value of this option does not
matter, as long as it is present.  See C<Mail::Message::Body::Multipart>.

 Option    --Defined in     --Default
 Bcc                          undef
 Cc                           undef
 Date                         <now>
 From                         <'to' in current>
 Message-ID                   <uniquely generated>
 Subject                      forwardSubject()
 To                           <required>
 body                         undef
 include                      <if body then 'NO' else C<'INLINE'>>
 preamble                     constructed from prelude and postlude
 signature                    undef

. Bcc ADDRESSES

=over 4

Receivers of blind carbon copies: their names will not be published to
other message receivers.

=back

. Cc ADDRESSES

=over 4

The carbon-copy receivers, by default none.

=back

. Date DATE

=over 4

The date to be used in the message sent.

=back

. From ADDRESSES

=over 4

Your identification, by default taken from the C<To> field of the
source message.

=back

. Message-ID STRING

=over 4

Supply a STRING as specific message-id for the forwarded message.
By default, one is generated for you.  If there are no angles around
your id, they will be added.

=back

. Subject STRING|CODE

=over 4

Force the subject line to the specific STRING, or the result of the
subroutine specified by CODE.  The subroutine will be called passing
the subject of the original message as only argument.  By default,
the L<forwardSubject()|Mail::Message::Construct::Forward/"Constructing a message"> method is used.

=back

. To ADDRESSES

=over 4

The destination of your message. Obligatory.  The ADDRESSES may be
specified as string, a Mail::Address object, or as array of
Mail::Address objects.

=back

. body OBJECT

=over 4

If you specify a fully prepared body OBJECT, it will be used as forwarded
message contents.  In this case, only the headers are constructed for you.

=back

. include 'NO'|'INLINE'|'ATTACH'|'ENCAPSULATE'

=over 4

Must the message where this is a reply to be included in the message?
When C<INLINE> is given, you may pass the options of L<forwardInline()|Mail::Message::Construct::Forward/"Constructing a message">
as well.

In many applications, the forward option C<as attachment> results in a
structure which is produced when this option is set to C<ENCAPSULATE>.
Their default behavior is usually C<INLINE>.

It is only possible to inline textual messages, therefore binary or
multi-part messages will always be enclosed as attachment.
Read the details in section L</Creating a forward>..

=back

. preamble STRING|BODY

=over 4

Part which is attached before the forwarded message.  If no preamble
is given, then it is constructed from the prelude and postlude.  When
these are also not present, you will still get a one liner: the result
of L<forwardPrelude()|Mail::Message::Construct::Forward/"Constructing a message">

=back

. signature BODY|MESSAGE

=over 4

The signature to be added in case of a multi-part forward.  The mime-type
of the signature body should indicate this is a used as such.  However,
in INLINE mode, the body will be taken, a line containing C<'-- '> added
before it, and added behind the epilogue.

=back

=back

$obj-E<gt>B<forwardAttach>(OPTIONS)

=over 4

Forward the message as I<flat> attachment to the specified C<preamble>.  You
can specify all options available to C<forward()>, although a C<preamble>
which is provided as body object is required, and any specified C<body>
is ignored.

 Option  --Defined in--Default
 preamble              <required>

. preamble BODY|PART

=back

$obj-E<gt>B<forwardEncapsulate>(OPTIONS)

=over 4

Like L<forwardAttach()|Mail::Message::Construct::Forward/"Constructing a message">, but in this case the original message is first
encapsulated as nested message in a L<Mail::Message::Body::Nested|Mail::Message::Body::Nested>, and
then joint into a multipart.

You can specify all options available to C<forward()>, although a C<preamble>
which is provided as body object is required, and any specified C<body>
is ignored.  Signatures are not stripped.  Signatures are not stripped.

 Option  --Defined in--Default
 preamble              <required>

. preamble BODY|PART

=back

$obj-E<gt>B<forwardInline>(OPTIONS)

=over 4

This method is equivalent in behavior to L<forward()|Mail::Message::Construct::Forward/"Constructing a message"> with the
option C<include> set to C<'INLINE'>.  You can specify most of
the fields which are available to L<forward()|Mail::Message::Construct::Forward/"Constructing a message"> except
C<include> and C<body>.

 Option         --Defined in     --Default
 is_attached                       "[The forwarded message is attached]\n"
 max_signature                     10
 postlude                          undef
 prelude                           undef
 quote                             undef
 strip_signature                   qr/^--\s/

. is_attached STRING

=over 4

A forward on binary messages can not be inlined.  Therefore, they are
automatically translated into an attachment, as made by L<forwardAttach()|Mail::Message::Construct::Forward/"Constructing a message">.
The obligatory preamble option to that method may be specified as option
to this method, to be used in case of such a forward of a binary, but
is otherwise constructed from the prelude, the value of this option, and
the postlude.

=back

. max_signature INTEGER

=over 4

Passed to L<Mail::Message::Body::stripSignature(max_lines)|Mail::Message::Body::Construct/"Constructing a body">.  Only
effective for single-part messages.

=back

. postlude BODY

=over 4

The line(s) which to be added after the quoted reply lines.  Create a
body for it first.  This should not include the signature, which has its
own option.  The signature will be added after the postlude when the
forwarded message is C<INLINE>d.

=back

. prelude BODY

=over 4

The line(s) which will be added before the quoted forwarded lines.
If nothing is specified, the result of the L<forwardPrelude()|Mail::Message::Construct::Forward/"Constructing a message"> method
is used.  When C<undef> is specified, no prelude will be added.

=back

. quote CODE|STRING

=over 4

Mangle the lines of an C<INLINE>d reply with CODE, or by prepending a
STRING to each line.  The routine specified by CODE is called when the
line is in C<$_>.

By default, nothing is added before each line.  This option is processed
after the body has been decoded.

=back

. strip_signature REGEXP|STRING|CODE

=over 4

Remove the signature of the sender.  The value of this parameter is
passed to L<Mail::Message::Body::stripSignature(pattern)|Mail::Message::Body::Construct/"Constructing a body">, unless the
source text is not included.  The signature is stripped from the message
before quoting.

=back

=back

$obj-E<gt>B<forwardNo>(OPTIONS)

=over 4

Construct a forward, where the whole body of the message is already
constructed.  That complex body is usually produced in L<forwardInline()|Mail::Message::Construct::Forward/"Constructing a message">,
L<forwardAttach()|Mail::Message::Construct::Forward/"Constructing a message">, or L<forwardEncapsulate()|Mail::Message::Construct::Forward/"Constructing a message">.

The OPTIONS are the same as for C<forward()> except that C<body> is
required.  Some other options, like C<preamble>, are ignored.

 Option--Defined in--Default
 body                <required>

. body BODY

=back

$obj-E<gt>B<forwardPostlude>

=over 4

Added after the forwarded message.

I<Example:> 

 ---- END forwarded message

=back

$obj-E<gt>B<forwardPrelude>

=over 4

Create a few lines to be included before the forwarded message
content.  The return is an array of lines.

I<Example:> 

 ---- BEGIN forwarded message
 From: him@somewhere.else.nl (Original Sender)
 To: me@example.com (Me the receiver)
 Cc: the.rest@world.net
 Date: Wed, 9 Feb 2000 15:44:05 -0500
 <blank line>

=back

$obj-E<gt>B<forwardSubject>(STRING)

=over 4

Create a subject for a message which is a forward from this one.  This routine
tries to count the level of reply in subject field, and transform it into
a standard form.  Please contribute improvements.

I<Example:> 

 subject                 --> Forw: subject
 Re: subject             --> Forw: Re: subject
 Re[X]: subject          --> Forw: Re[X]: subject
 <blank>                 --> Forwarded

=back




=head1 DIAGNOSTICS

I<Error:> Cannot include forward source as $include.

Unknown alternative for the L<forward(include)|Mail::Message::Construct::Forward/"Constructing a message">.  Valid choices are
C<NO>, C<INLINE>, C<ATTACH>, and C<ENCAPSULATE>.

I<Error:> Method forwardAttach requires a preamble


I<Error:> Method forwardEncapsulate requires a preamble


I<Error:> No address to create forwarded to.

If a forward message is created, a destination address must be specified.


=head1 DETAILS


=head2 Creating a forward

The main difference between L<bounce()|Mail::Message::Construct::Bounce/"Constructing a message"> and L<forward()|Mail::Message::Construct::Forward/"Constructing a message"> is the reason
for message processing.  The I<bounce> has no intention to modify the
content of message: the same information is passed-on to someplace else.
This may mean some conversions, but for instance, the Message-ID does
not need to be changed.

The purpose of I<forward()> is to pass on information which is
modified: annotated or reduced.  The information is not sent back
to the author of the original message (which is implemented by L<reply()|Mail::Message::Construct::Reply/"Constructing a message">),
but to someone else.

So: some information comes in, is modified, and than forwarded to someone
else.  Currently, there are four ways to get the original information
included, which are explained in the next sections.

After the creation of the forward, you may want to L<rebuild()|Mail::Message::Construct::Rebuild/"Constructing a message"> the
message to remove unnecessary complexities.  Of course, that is not
required.

=head3 forward, specify a body

When you specify L<forward(body)|Mail::Message::Construct::Forward/"Constructing a message">, you have created your own body object to
be used as content of the forwarded message.  This implies that
L<forward(include)|Mail::Message::Construct::Forward/"Constructing a message"> is C<'NO'>: no automatic generation of the forwarded
body.

=head3 forward, inline the original

The L<forward(include)|Mail::Message::Construct::Forward/"Constructing a message"> is set to C<'INLINE'> (the default)
This is the most complicated situation, but most often used by MUAs:
the original message is inserted textually in the new body.  You can
set-up automatic stripping of signatures, the way of encapsulation,
and texts which should be added before and after the encapsulated part.

However, the result may not always be what you expect.  For instance,
some people use very long signatures which will not be automatically
stripped because the pass the threshold.  So, you probably need some
manual intervention after the message is created and before it is sent.

When a binary message is encountered, inlining is impossible.  In that
case, the message is treated as if C<'ENCAPSULATE'> was requested.

=head3 forward, attach the original

When L<forward(include)|Mail::Message::Construct::Forward/"Constructing a message"> is explicitly set to C<'ATTACH'> the result
will be a multipart which contains two parts.  The first part will
be your message, and the second the body of the original message.

This means that the headers of the forwarded message are used for
the new message, and detached from the part which now contains the
original body information.  Content related headers will (of course)
still be part of that part, but lines line C<To> and C<Subject> will
not be stored with that part.

As example of the structural transformation:

 # code: $original->printStructure;
 multipart/alternative: The source message
   text/plain: content in raw text
   text/html: content as html

 # code: $fwd = $original->forward(include => 'ATTACH');
 # code: $fwd->printStructure
 multipart/mixed: The source message
   text/plain: prelude/postlude/signature
   multipart/alternative
     text/plain: content in raw text
     text/html: content as html

=head3 forward, encapsulate the original

When L<forward(include)|Mail::Message::Construct::Forward/"Constructing a message"> is explicitly set to C<'ENCAPSULATE'>, then
the original message is left in-tact as good as possible.  The lines
of the original message are used in the main message header but also
enclosed in the part header.

The encapsulation is implemented using a nested message, content type
C<message/rfc822>.  As example of the structural transformation:

 # code: $original->printStructure;
 multipart/alternative: The source message
   text/plain: content in raw text
   text/html: content as html

 # code: $fwd = $original->forward(include => 'ENCAPSULATE');
 # code: $fwd->printStructure
 multipart/mixed: The source message
   text/plain: prelude/postlude/signature
   message/rfc822
      multipart/alternative: The source message
         text/plain: content in raw text
         text/html: content as html

The message structure is much more complex, but no information is lost.
This is probably the reason why many MUAs use this when the forward
an original message as attachment.





=head1 REFERENCES

See the MailBox website at L<http://perl.overmeer.net/mailbox/> for more details.

=head1 COPYRIGHTS

Distribution version 2.068.
Written by Mark Overmeer (mark@overmeer.net).  See the ChangeLog for
other contributors.

Copyright (c) 2001-2006 by the author(s). All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.