Mail::Message::Construct::Forward(3pm) | User Contributed Perl Documentation | Mail::Message::Construct::Forward(3pm) |
Mail::Message::Construct::Forward - forwarding a Mail::Message
my Mail::Message $forward = $message->forward(To => 'you'); $forward->send;
Complex functionality on Mail::Message objects is implemented in different files which are autoloaded. This file implements the functionality related to creating forwarded messages.
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 "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 "Mail::Message::Body::Multipart".
-Option --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
In many applications, the forward option "as attachment" results in a structure which is produced when this option is set to "ENCAPSULATE". Their default behavior is usually "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 "Creating a forward"..
-Option --Default preamble <required>
You can specify all options available to "forward()", although a "preamble" which is provided as body object is required, and any specified "body" is ignored. Signatures are not stripped. Signatures are not stripped.
-Option --Default preamble <required>
-Option --Default is_attached "[The forwarded message is attached]\n" max_signature 10 postlude undef prelude undef quote undef strip_signature qr/^--\s/
By default, nothing is added before each line. This option is processed after the body has been decoded.
The %options are the same as for "forward()" except that "body" is required. Some other options, like "preamble", are ignored.
-Option--Default body <required>
example:
---- END forwarded message
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>
example:
subject --> Forw: subject Re: subject --> Forw: Re: subject Re[X]: subject --> Forw: Re[X]: subject <blank> --> Forwarded
The main difference between bounce() and forward() is the reason for message processing. The 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 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 reply()), 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 rebuild() the message to remove unnecessary complexities. Of course, that is not required.
forward, specify a body
When you specify forward(body), you have created your own body object to be used as content of the forwarded message. This implies that forward(include) is 'NO': no automatic generation of the forwarded body.
forward, inline the original
The forward(include) is set to '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 'ENCAPSULATE' was requested.
forward, attach the original
When forward(include) is explicitly set to '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 "To" and "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
forward, encapsulate the original
When forward(include) is explicitly set to '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 "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.
This module is part of Mail-Message distribution version 3.008, built on February 11, 2019. Website: http://perl.overmeer.net/CPAN/
Copyrights 2001-2019 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
2019-02-15 | perl v5.28.1 |