NAME

Mail::Make::Body::File - On-Disk Body for Mail::Make

SYNOPSIS

use Mail::Make::Body::File;
my $body = Mail::Make::Body::File->new( '/path/to/logo.png' ) ||
    die( Mail::Make::Body::File->error );
my $fh = $body->open || die( $body->error );

VERSION

v0.1.0

DESCRIPTION

Holds a reference to a file on disk. The file is read lazily when open() or as_string() is called.

CONSTRUCTOR

new( $filepath )

Accepts an absolute or relative file path. The file must exist and be readable at construction time or the constructor will fail with an explicit error.

METHODS

as_string

Slurps the entire file and returns a scalar reference. Use with caution on large files.

is_on_file

Returns true (1).

length

Returns the file size in bytes from stat().

open

Opens the file in raw binary mode and returns the filehandle.

path( [$newpath] )

Gets or sets the file path. When setting, validates that the new path exists and is readable.

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Mail::Make::Body::InCore, Mail::Make::Body, Mail::Make

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.