NAME
Mail::Make::Stream::Base64 - Streaming Base64 Encoder/Decoder for Mail::Make
SYNOPSIS
use Mail::Make::Stream::Base64;
my $s = Mail::Make::Stream::Base64->new ||
die( Mail::Make::Stream::Base64->error, "\n" );
# File to file
$s->encode( '/path/to/logo.png' => '/tmp/logo.b64' ) ||
die( $s->error );
# Scalar ref to scalar ref
my( $raw, $out ) = ( "Hello, world!" );
$s->encode( \$raw => \$out ) || die( $s->error );
# Decode
my $decoded = '';
$s->decode( \$out => \$decoded ) || die( $s->error );
# Exportable wrappers
use Mail::Make::Stream::Base64 qw( encode_b64 decode_b64 );
encode_b64( \$raw => \$out ) ||
die( $Mail::Make::Stream::Base64::Base64Error );
VERSION
v0.3.0
DESCRIPTION
RFC 2045 compliant Base64 encoder and decoder. Both "encode" and "decode" operate as stream pipelines: data is read from $from in chunks and written to $to without accumulating the full content in memory, making them safe for large attachments backed by Mail::Make::Body::File.
Each of $from and $to may be:
A native filehandle or IO object
A scalar reference (
\$scalar)A plain string (file path)
METHODS
decode( $from, $to )
Reads base64-encoded data from $from, decodes it via MIME::Base64, and writes the raw bytes to $to. Returns $self on success, undef on error.
encode( $from, $to [, %opts] )
Reads raw bytes from $from in 300-byte chunks, encodes them as RFC 2045 base64 folded at 76 characters per line, and writes the result to $to.
Returns $self on success, undef on error.
Options:
eol-
Line ending appended after each 76-character line. Defaults to CRLF (
"\015\012"). Passundefor""to suppress line folding.
CLASS FUNCTIONS
The following functions are exportable on request:
use Mail::Make::Stream::Base64 qw( encode_b64 decode_b64 );
encode_b64( $from, $to [, %opts] )
Convenience wrapper for "encode". Sets $Base64Error and returns undef on failure.
decode_b64( $from, $to )
Convenience wrapper for "decode". Sets $Base64Error and returns undef on failure.
is_encoder_installed
is_decoder_installed
Return true if MIME::Base64 is available.
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
Mail::Make, Mail::Make::Entity, Mail::Make::Stream::QuotedPrint, Mail::Make::Stream, MIME::Base64
RFC 2045
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.