Email:...tripper(3pm)

πŸ“¦
version 1.317 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’Œ 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


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