Sisimai::MIME(3pm)
π Sisimai::MIME β the MIME utilities era π
okay bestie, sit down, hydrate, because this is the Sisimai::MIME page from the User Contributed Perl Documentation and it's genuinely so useful. it's the little toolkit that handles all the MIME nonsense hiding inside email headers. no cap. π
β¨ NAME β¨
Sisimai::MIME β MIME Utilities π¦
β¨ SYNOPSIS β¨
lowkey just load it and go:
use Sisimai::MIME;
my $e = '=?utf-8?B?55m954yr44Gr44KD44KT44GT?=';
my $v = Sisimai::MIME->is_mimeencoded(\$e);
print $v; # 1
my $x = Sisimai::MIME->mimedecode([$e]);
print $x;
see that? is_mimeencoded says 1 (yes bestie it IS encoded) and mimedecode hands you back the actual readable string. main character behaviour. π
β¨ DESCRIPTION β¨
Sisimai::MIME is MIME Utilities for "Sisimai". that's it, that's the vibe. it does the messy decoding work so the rest of Sisimai doesn't have to. π«Ά
β¨ CLASS METHODS β¨
πΈ is_mimeencoded(Scalar Reference)
is_mimeencoded() returns that the argument is MIME-Encoded string or not.
ngl the answer comes back as a truthy 1 when it's encoded. vibe check passed β
my $e = '=?utf-8?B?55m954yr44Gr44KD44KT44GT?=';
my $v = Sisimai::MIME->is_mimeencoded(\$e); # 1
πΈ mimedecode(Array-Ref)
mimedecode() is a decoder method for getting the original string from MIME Encoded string in email headers.
it's giving "unscramble the header" energy. pass an array ref, get the real text back π₯
my $r = '=?utf-8?B?55m954yr44Gr44KD44KT44GT?=';
my $v = Sisimai::MIME->mimedecode([$r]);
πΈ base64d(\String)
base64d is a decoder method for getting the original string from MIME Base564 encoded string.
yes bestie, the original really says Base564. we are reporting it exactly as written. periodt. π
my $r = '44Gr44KD44O844KT';
my $v = Sisimai::MIME->base64d(\$r);
πΈ qprintd(\String)
qprintd is a decoder method for getting the original string from MIME Quoted- printable encoded string.
(the original has that lil space in "Quoted- printable", keeping it, iconic typo behaviour π )
my $r = '=4e=65=6b=6f';
my $v = Sisimai::MIME->qprintd(\$r);
πΈ boundary(String)
boundary() returns a boundary string from the value of Content-Type header.
this one is so satisfying honestly. feed it a header, get the boundary back. and you can ask for the decorated versions too π
my $r = 'Content-Type: multipart/mixed; boundary=Apple-Mail-1-526612466';
my $v = Sisimai::MIME->boundary($r);
print $v; # Apple-Mail-1-526612466
print Sisimai::MIME->boundary($r, 0); # --Apple-Mail-1-526612466
print Sisimai::MIME->boundary($r, 1); # --Apple-Mail-1-526612466--
so: no second arg β just the raw boundary. 0 β the opening -- version. 1 β the closing --...-- version. slay. β¨
πΈ breaksup(\String, String)
breaksup is a multipart/* message decoder: Decode quoted-printable, base64, and other encoded message part, leave only text/plain, message/*, text/html (only in multipart/alternative), returns string as a reference. This method is called from makeflat() and breaksup() itself.
yes bestie it calls itself. recursive queen behaviour π it keepstext/plain,message/*, andtext/html(but only when it's insidemultipart/alternative) and yeets everything else, returning a reference to the string.
πΈ makeflat(String, \String)
makeflat makes flat multipart/* message: it leaves only text/html, message/, and text/html (Content-Type of upper part is not multipart/alternative) part. In other words, this method remove parts which is not needed to parse bounce message such as image/, text/html inside of multipart/alternative.
flattening a whole multipart message into one clean blob so the bounce parser doesn't have to deal with random image/* parts. the way that it just β¨removesβ¨ the irrelevant stuff. obsessed. π
my $r = 'multipart/report; ...'; # Content-Type: MIME type, boundary
my $b = '...'; # Multipart message body
my $v = Sisimai::MIME->makeflat($r, \$b); # Returns scalar reference
print $$v; # Flatten message body
heads up: the return value is a scalar reference, so deref it with $$v before printing, bestie π
β¨ AUTHOR β¨
azumakuniyuki β the legend themselves π«Ά
β¨ COPYRIGHT β¨
Copyright (C) 2014-2016,2018-2020 azumakuniyuki, All rights reserved.
β¨ LICENSE β¨
This software is distributed under The BSD 2-Clause License. go read it, it's short and sweet π
and that's the whole page, bestie!! this was documented as Sisimai::MIME(3pm) for perl v5.36.0, dated 2022-12-23. mwah. stay decoded, stay iconic. π
ππ¦β¨
π¦ where this page comes from
- debian bookworm: libsisimai-perl 4.25.15-1 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms