The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Sisimai::RFC2045 - MIME Utilities

SYNOPSIS

    use Sisimai::RFC2045;

    my $e = '=?utf-8?B?55m954yr44Gr44KD44KT44GT?=';
    my $v = Sisimai::RFC2045->is_encoded(\$e);
    print $v;   # 1

    my $x = Sisimai::RFC2045->decodeH([$e]);
    print $x;

DESCRIPTION

Sisimai::RFC2045 is MIME Utilities for Sisimai, is formerly known as Sisimai::MIME.

CLASS METHODS

is_encoded(Scalar Reference)

is_encoded() returns that the argument is MIME-Encoded string or not.

    my $e = '=?utf-8?B?55m954yr44Gr44KD44KT44GT?=';
    my $v = Sisimai::RFC2045->is_encoded(\$e);  # 1

decodeH(Array-Ref)

decodeH() is a decoder method for getting the original string from MIME-Encoded string in email headers.

    my $r = '=?utf-8?B?55m954yr44Gr44KD44KT44GT?=';
    my $v = Sisimai::RFC2045->decodeH([$r]);

decodeB(\String)

decodeB is a decoder method for getting the original string from MIME Base64 encoded string.

    my $r = '44Gr44KD44O844KT';
    my $v = Sisimai::RFC2045->decodeB(\$r);

decodeQ(\String)

decodeQ is a decoder method for getting the original string from MIME quoted-printable encoded string.

    my $r = '=4e=65=6b=6f';
    my $v = Sisimai::RFC2045->decodeQ(\$r);

parameter(String, String)

parameter() returns the value of parameter in Content-Type header.

    my $r = 'Content-Type: multipart/mixed; boundary=Apple-Mail-1-526612466'; charset=utf8;
    print Sisimai::RFC2045->parameter($r, 'charset');  # utf8
    print Sisimai::RFC2045->parameter($r, 'boundary'); # Apple-Mail-1-526612466
    print Sisimai::RFC2045->parameter($r);             # multipart/mixed

boundary(String, Integer)

boundary() returns a boundary string from the value of Content-Type header.

    my $r = 'Content-Type: multipart/mixed; boundary=Apple-Mail-1-526612466';
    my $v = Sisimai::RFC2045->boundary($r);
    print $v;   # Apple-Mail-1-526612466

    print Sisimai::RFC2045->boundary($r, 0); # --Apple-Mail-1-526612466
    print Sisimai::RFC2045->boundary($r, 1); # --Apple-Mail-1-526612466--

haircut(\String, Boolean)

haircut() remove unused headers from multipart/* block.

levelout(String, \String)

levelout breaks multipart/* message block into each part and returns an array reference.

makeflat(String, \String)

makeflat makes flat multipart/* message: This method breaks multipart/* block into each part, remove parts which are not needed to parse a bounce message such as image/* MIME type, and decode an encoded text part (text/*, message/*) in a body of each part that has Content-Transfer-Encoding header and the value of the header is quoted-printabe, base64, or 7bit.

AUTHOR

azumakuniyuki

COPYRIGHT

Copyright (C) 2014-2016,2018-2023 azumakuniyuki, All rights reserved.

LICENSE

This software is distributed under The BSD 2-Clause License.