NAME

Mail::Make::Headers::ContentType - Content-Type Header Field Object

SYNOPSIS

use Mail::Make::Headers::ContentType;

my $ct = Mail::Make::Headers::ContentType->new( 'text/plain' ) ||
    die( Mail::Make::Headers::ContentType->error );
$ct->charset( 'utf-8' );
print "$ct";
# text/plain; charset=utf-8

my $ct = Mail::Make::Headers::ContentType->new( 'multipart/mixed' ) ||
    die( Mail::Make::Headers::ContentType->error );
$ct->boundary( $ct->make_boundary );
print "$ct";
# multipart/mixed; boundary=550E8400-E29B-41D4-A716-446655440000

VERSION

v0.1.0

DESCRIPTION

Typed object for the Content-Type mail header field. Provides strict validation of the MIME type, charset, and boundary parameter, refusing silently corrupt values that would produce a broken message.

METHODS

new( $mime_type [, %params ] )

Instantiates a new object. $mime_type must be in type/subtype format. Optional %params are set as additional parameters on the header value.

as_string

Returns the complete header field value as a string, including all parameters.

boundary( [ $boundary ] )

Sets or gets the boundary parameter. On setting, validates that the value conforms to RFC 2046: up to 70 characters from the set [0-9A-Za-z'()+_,-./:=? ], with no trailing space.

Returns an error if the boundary is invalid.

charset( [ $charset ] )

Sets or gets the charset parameter. On setting, validates the value against a list of known charsets and normalises utf8 to utf-8.

make_boundary

Returns a freshly generated, RFC 2046 compliant boundary string based on a UUID.

name( [ $name ] )

Sets or gets the name parameter (used for inline parts).

type( [ $mime_type ] )

Sets or gets the MIME type (e.g. text/html). Validates the type/subtype format on assignment.

value( [ $mime_type ] )

Alias for "type".

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Mail::Make, Mail::Make::Headers, Mail::Make::Headers::Generic, Mail::Make::Headers::ContentDisposition

RFC 2045, RFC 2046

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.