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. default true. 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. default HTML. 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 $subject can 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 by fieldContentsToHtml(). 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 the selectedFields() of the header in a table shape. the optional $table_params are added as parameters to the produced TABLE tag. 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 $lines from 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 by notImplemented(). 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 to produce, 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