Email:...tripper(3pm)
π Email::MIME::Attachment::Stripper π
okay bestie, sit down, because this is the module that takes your email and gently removes the attachments from it. it's Email::MIME::Attachment::Stripper, it lives in the 3pm manual, and it's part of the User Contributed Perl Documentation situation. it's giving very specific little tool and honestly? we love that for it.
β¨ VERSION β¨
version 1.317
that's the one. that's the number. don't @ me.
πΈ SYNOPSIS πΈ
the vibe, in code:
my $stripper = Email::MIME::Attachment::Stripper->new($mail);
my $msg = $stripper->message;
my @attachments = $stripper->attachments;
yes that's literally it, that's the whole first impression, and it ate. π
π¦ DESCRIPTION π¦
so here's the deal: you hand this thing an Email::MIME object, and it detaches all the attachments from the message and hands them to you separately. like, "here's your email, and here's all the extra stuff that was riding along with it, no biggie." π
the message you're left with? it might still be multipart. but it should only be multipart/alternative or multipart/related. those are the acceptable leftovers. that's the rule. periodt.
okay picture this message:
+ multipart/mixed
- text/plain
- application/pdf; disposition=attachment
the PDF gets stripped. gone. bye. π
but here's the thing β and i need you to really hear me β whether the returned message ends up as a single text/plain part, or as a multipart/mixed message with only the text/plain part still hanging out inside it, is not yet guaranteed one way or the other. it could be either. nobody pinky-promised. that's just the situation. π
π METHODS π
new
my $stripper = Email::MIME::Attachment::Stripper->new($email, %args);
the constructor, bestie. you can pass it an Email::MIME object, a reference to a string, or literally any other value that Email::Abstract (if it's available) can cast to an Email::MIME object. so flexible. so iconic. β¨
valid arguments include:
force_filenameβ try harder to get a filename, making one up if necessary. it will invent one. it's committed. π«Ά
message
my $email_mime = $stripper->message;
this returns the message with all the attachments detached. and heads up: this will alter both the body and the header of the message. both of them. it's not subtle about it. π
attachments
my @attachments = $stripper->attachments;
this returns a list of all the attachments we found in the message, as a hash of { filename, content_type, payload }. π
and ngl, this may contain parts that might not normally be considered attachments, like text/html or multipart/alternative. so like... it's generous. it's not gatekeeping. π
β οΈ ATTENTION! β οΈ
okay this is the serious one, so listen up.
this module's behavior has never been very clearly spelled out, and that has led to misunderstandings and bug reports, which may or may not be actual bugs. like, genuinely. it's messy. π
the author plans to take some significant action to address this. to read more or comment, please see:
https://github.com/rjbs/Email-MIME-Attachment-Stripper/issues/2
go read the issue, bestie. the tea is there. π
π CREDITS AND LICENSE π
this module is incredibly closely derived from Tony Bowden's Mail::Message::Attachment::Stripper. like, extremely closely. the derivation was done by Simon Cozens (simon@cpan.org), and you receive this under the same terms as Tony's original module. credit where credit is due, always. π
π AUTHOR π
Simon Cozens
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2004 by Simon Cozens.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay. π
and that's a wrap on the Email:...tripper(3pm) page, babes β brought to you by perl v5.34.0 and dated 2022-06-13. thanks for coming to my ted talk, go strip some attachments responsibly. β¨π¦πΈ
π¦ where this page comes from
- debian bookworm: libemail-mime-attachment-stripper-perl 1.317-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libemail-mime-attachment-stripper-perl 1.317-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libemail-mime-attachment-stripper-perl 1.317-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libemail-mime-attachment-stripper-perl 1.317-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libemail-mime-attachment-stripper-perl 1.317-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms