NAME
Mail::Make::Body - MIME Body Base Class for Mail::Make
SYNOPSIS
use Mail::Make::Body;
# In-memory body
my $b = Mail::Make::Body::InCore->new( "Hello, world!" ) ||
die( Mail::Make::Body::InCore->error );
my $ref = $b->as_string; # scalar ref
print $$ref;
# File-backed body
my $f = Mail::Make::Body::File->new( '/path/to/logo.png' ) ||
die( Mail::Make::Body::File->error );
my $ref = $f->as_string; # reads entire file into memory
VERSION
v0.1.0
DESCRIPTION
Mail::Make::Body is the abstract base class for MIME body objects used by Mail::Make::Entity. Two concrete subclasses are provided in the same file:
- "Mail::Make::Body::InCore"
-
Holds the body content in memory as a scalar. Suitable for text parts and small attachments assembled at runtime.
- "Mail::Make::Body::File"
-
Holds a path to a file on disk. Content is read on demand by "as_string". The file is validated for existence and readability at construction time.
METHODS (Mail::Make::Body)
as_string
Returns a scalar reference to the body content. Must be overridden by subclasses.
data
Alias for "as_string".
is_in_core
Returns 1 if this is a Mail::Make::Body::InCore object, 0 otherwise.
is_on_file
Returns 1 if this is a Mail::Make::Body::File object, 0 otherwise.
length
Returns the byte length of the body content.
path
Returns undef for the base class. Overridden by Mail::Make::Body::File.
purge
Releases the body content. Subclasses override.
METHODS (Mail::Make::Body::InCore)
new( [ $data ] )
Creates a new in-memory body. $data may be a plain scalar or a scalar reference.
set( $data )
Replaces the stored data after construction.
METHODS (Mail::Make::Body::File)
new( [ $path ] )
Creates a new file-backed body. Validates that $path exists and is readable.
path( [ $path ] )
Sets or gets the file path. Validates existence and readability on assignment.
purge
Deletes the file from disk and clears the path.
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
Mail::Make, Mail::Make::Entity
COPYRIGHT & LICENSE
Copyright(c) 2026 DEGUEST Pte. Ltd.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.