Mail::Message::Body::Encode(3pm) | User Contributed Perl Documentation | Mail::Message::Body::Encode(3pm) |
Mail::Message::Body::Encode - organize general message encodings
my Mail::Message $msg = ...; my $decoded = $msg->decoded; my $encoded = $msg->encode(mime_type => 'image/gif', transfer_encoding => 'base64'); my $body = $msg->body; my $decoded = $body->decoded; my $encoded = $body->encode(transfer_encoding => '7bit');
Manages the message's body encodings and decodings on request of the main program. This package adds functionality to the Mail::Message::Body class when the decoded() or encode() method is called.
Four types of encodings are handled (in the right order)
Various operating systems have different ideas about how to encode the line termination. UNIX uses a LF character, MacOS uses a CR, and Windows uses a CR/LF combination. Messages which are transported over Internet will always use the CRLF separator.
Messages transmitted over Internet have to be plain ASCII. Complicated characters and binary files (like images and archives) must be encoded during transmission to an ASCII representation.
The implementation of the required encoders and decoders is found in the Mail::Message::TransferEnc set of packages. The related manual page lists the transfer encodings which are supported.
NOT IMPLEMENTED YET
-Option --Default external <false>
When you call this method with an explicit "undef", you reset the default. (Without parameter) the current algorithm (CODE or method name) is returned.
A body is returned which is checked. This may be the body where this method is called upon, but also a new object, when serious changes had to be made. If the check could not be made, because the decoder is not defined, then "undef" is returned.
-Option --Default charset PERL charset_detect <built-in> mime_type undef result_type <same as source> transfer_encoding undef
If the CHARSET is explicitly specified (for instance "iso-8859-10", then the data is being interpreted as raw bytes (blob), not as text. However, in case of "PERL", it is considered to be an internal representation of characters (either latin1 or Perl's utf8 --not the same as utf-8--, you should not want to know).
This setting overrules the charset attribute in the mime_type FIELD.
When you want to be smarter than the default charset detector, you can provide your own function for this parameter. The function will get the transfer-decoded version of this body. You can change the default globally via charsetDetectAlgorithm().
The FIELD may contain attributes. Usually, it has a "charset" attribute, which explains the CHARSET of the content after content transfer decoding. The "charset" option will update/add this attribute. Otherwise (hopefully in rare cases) the CHARSET will be auto-detected when the body gets decoded.
-Option --Default charset_detect <the default>
Examples:
my $bodytype = Mail::Message::Body::Lines; my $html = $bodytype->new(mime_type=>'text/html', data => []); my $plain = $bodytype->new(mime_type=>'text/plain', ...); my $unified = $html->unify($plain); # $unified is the data of plain translated to html (if possible).
When a $directory is given, a filename is composed. For security reasons, only the basename of the found name gets used and many potentially dangerous characters removed. If no name was found, or when the found name is already in use, then an unique name is generated.
Don't forget to read RFC6266 section 4.3 for the security aspects in your email application.
The $class or $object must extend Mail::Message::TransferEnc. It will replace existing class and object for this $name.
Why aren't you contributing this class to MailBox?
This module is part of Mail-Message distribution version 3.015, built on December 11, 2023. Website: http://perl.overmeer.net/CPAN/
Copyrights 2001-2023 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/
2023-12-11 | perl v5.36.0 |