Mail::M...t::Html(3)
π Mail::M...t::Html(3) β the vibe β¨
okay bestie, so this is a page from the User Contributed Perl Documentation, filed under Mail::M...t::Html(3) π
. Yes, the title is literally abbreviated with dots, she's mysterious like that. Anyway. Sit down, grab a strawberry π, we're learning how messages get turned into HTML.
πΈ NAME πΈ
Mail::Message::Convert::Html β the thing that formats your messages in HTML. fr fr that's the whole job.
π¦ INHERITANCE π¦
the family tree, and yes she's got lineage:
Mail::Message::Convert::Html
is a Mail::Message::Convert
is a Mail::Reporter
so like, she inherited everything from those two and she's thriving.
β¨ SYNOPSIS β¨
the quick lil taste test:
use Mail::Message::Convert::Html;
my $Html = Mail::Message::Convert::Html->new;
print $html->fieldToHtml($head);
print $html->headToHtmlHead($head);
print $html->headToHtmlTable($head);
print $html->textToHtml($text);
(yes, the variable is $Html in one line and $html in the next four. she contains multitudes π. copy it exactly, i don't make the rules.)
π DESCRIPTION π
this package is a lil collection of translators that handle HTML or XHTML all by herself, no external modules needed, no outside help, independent queen energy π.
but also β there are more HTML-related modules out there, and those ones do require extra packages to be installed. so if you need the deluxe version, that's a different girl.
she extends "DESCRIPTION" in Mail::Message::Convert.
π METHODS π
extends "METHODS" in Mail::Message::Convert.
π Constructors
extends "Constructors" in Mail::Message::Convert.
$class->new(%options)
inherited, see "Constructors" in Mail::Reporter.
here's the options table, serving looks:
-Option --Defined in --Default
fields Mail::Message::Convert <see description>
head_mailto true
produce HTML
fields => $name|$regex|\@names|\@regexesβ your field situation. (defined in Mail::Message::Convert, default is<see description>)head_mailto => BOOLEANβ whether to replace e-mail addresses in some header lines with links. defaulttrue. like, she'll linkify those addresses for you, cute.produce => 'HTML'|'XHTML'β produce HTML or XHTML output. the output is slightly different, even html browsers will usually accept the XHTML data. defaultHTML. pick your aesthetic π¨
π§ Attributes
extends "Attributes" in Mail::Message::Convert.
π Converting
extends "Converting" in Mail::Message::Convert.
$obj->fieldContentsToHtml( $field, [$subject] )β format one field from the header to HTML. when the header line usually contains e-mail addresses, the line is scanned and valid addresses are linked with an"mailto:"anchor. the$subjectcan be specified to be included in that link.$obj->fieldToHtml( $field, [$subject] )β reformat one header line field to HTML. the$field's name is printed in bold, followed by the formatted field content, which is produced byfieldContentsToHtml(). so like, she does the styling and then hands it off π«Ά$obj->headToHtmlHead($head, $meta)β translate the selected header lines (fields) to an html page header. each selected field will get its own meta line with the same name as the line. furthermore, the"Subject"field will become the"title", and"From"is used for the"Author".
besides, you can specify your own meta fields, which will overrule header fields. empty fields will not be included. when a "title" is specified, this will become the html title, otherwise the "Subject" field is taken. in list context, the lines are separately, where in scalar context the whole text is returned as one.
if you need to add lines to the head (for instance, http-equiv lines), then splice them before the last element in the returned list. important!! the last element. not the end. before the last one. don't mess it up π
Β» example:
my @head = $html->headToHtmlHead(
$head,
description => 'This is a message',
generator => 'Mail::Box',
);
splice @head, -1, 0, '<meta http-equiv=...>';
print @head;
$obj->headToHtmlTable( $head, [$table_params] )β produce a display of theselectedFields()of the header in a table shape. the optional$table_paramsare added as parameters to the producedTABLEtag. in list context, the separate lines are returned. in scalar context, everything is returned as one.
Β» example:
print $html->headToHtmlTable($head, 'width="50%"');
table era πβ¨
$obj->selectedFields($head)β inherited, see"Converting"in Mail::Message::Convert.$obj->textToHtml($lines)β translate one or more$linesfrom text into HTML. each line is taken one after the other, and only simple things are translated."textToHtml"is able to convert large plain texts in a descent fashion. in scalar context, the resulting lines are returned as one.
(yes, the original says "descent" and not "decent". we respect the source text in this house π)
π Error handling
extends "Error handling" in Mail::Message::Convert.
$obj->AUTOLOAD()β inherited, see"Error handling"in Mail::Reporter.$obj->notImplemented()β inherited, see"Error handling"in Mail::Reporter.
π§Ή Cleanup
extends "Cleanup" in Mail::Message::Convert.
$obj->DESTROY()β inherited, see"Cleanup"in Mail::Reporter. she cleans up after herself, periodt.
π DIAGNOSTICS π
the "something went wrong bestie" section:
- Error: class $package does not implement method $method. fatal error: the specific
$package(or one of its superclasses) does not implement this method where it should. this message means that some other related classes do implement this method however the class at hand does not. probably you should investigate this and probably inform the author of the package. cast bynotImplemented(). like, the method exists somewhere in the family but not on this specific class. awkward π - Error: produce XHTML or HTML, not $what. cast by
new(). so if you pass literally anything else toproduce, she's gonna say something. only'XHTML'or'HTML', bestie, those are the options.
π SEE ALSO π
this module is part of Mail-Message version 4.04, built on February 04, 2026. Website: http://perl.overmeer.net/CPAN/
π LICENSE π
for contributors see file ChangeLog.
this software is copyright (c) 2001-2026 by Mark Overmeer.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, bestie β¨ this was perl v5.42.0, dated 2026-02-05, served fresh from Mail::M...t::Html(3) π you understood all of it, no cap, i'm so proud of you π«Ά go write some HTML π
π¦ where this page comes from
- fedora 44: perl-Mail-Message 4.04-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms