Mail-Message-4.05/ 0000755 0001750 0000144 00000000000 15166136132 014430 5 ustar 00markov users 0000000 0000000 Mail-Message-4.05/lib/ 0000755 0001750 0000144 00000000000 15166136132 015176 5 ustar 00markov users 0000000 0000000 Mail-Message-4.05/lib/Mail/ 0000755 0001750 0000144 00000000000 15166136132 016060 5 ustar 00markov users 0000000 0000000 Mail-Message-4.05/lib/Mail/Message/ 0000755 0001750 0000144 00000000000 15166136132 017444 5 ustar 00markov users 0000000 0000000 Mail-Message-4.05/lib/Mail/Message/Convert/ 0000755 0001750 0000144 00000000000 15166136132 021064 5 ustar 00markov users 0000000 0000000 Mail-Message-4.05/lib/Mail/Message/Convert/Html.pm 0000644 0001750 0000144 00000007261 15166136116 022336 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Convert::Html;{
our $VERSION = '4.05';
}
use parent 'Mail::Message::Convert';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw/__x error/ ];
#--------------------
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
my $produce = $args->{produce} || 'HTML';
$self->{MMCH_tail}
= $produce eq 'HTML' ? '>'
: $produce eq 'XHTML' ? ' />'
: error __x"produce XHTML or HTML, not {what UNKNOWN}.", what => $produce;
$self;
}
#--------------------
sub textToHtml(@)
{ my $self = shift;
my @lines = @_; # copy is required
foreach (@lines)
{ s/\&/&/gs; s/\</gs;
s/\>/>/gs; s/\"/"/gs;
}
wantarray ? @lines : join('', @lines);
}
sub fieldToHtml($;$)
{ my ($self, $field, $subject) = @_;
''. $self->textToHtml($field->wellformedName) . ': ' . $self->fieldContentsToHtml($field, $subject);
}
sub headToHtmlTable($;$)
{ my ($self, $head) = (shift, shift);
my $tp = @_ ? ' '.shift : '';
my $subject;
if($self->{MMHC_mailto_subject})
{ my $s = $head->get('subject');
use Mail::Message::Construct;
$subject = Mail::Message::Construct->replySubject($s) if defined $s;
}
my @lines = "
\n";
foreach my $f ($self->selectedFields($head))
{ my $name_html = $self->textToHtml($f->wellformedName);
my $cont_html = $self->fieldContentsToHtml($f, $subject);
push @lines,
qq(| $name_html: | \n),
qq( $cont_html |
\n);
}
push @lines, "
\n";
wantarray ? @lines : join('',@lines);
}
sub headToHtmlHead($@)
{ my ($self, $head) = (shift,shift);
my %meta;
while(@_) { my $k = shift; $meta{lc $k} = shift }
my $title = delete $meta{title} || $head->get('subject') || '';
my @lines = (
"\n",
"".$self->textToHtml($title) . "\n",
);
my $author = delete $meta{author};
unless(defined $author)
{ my $from = $head->get('from');
my @addr = defined $from ? $from->addresses : ();
$author = @addr ? $addr[0]->format : undef;
}
push @lines, '{MMCH_tail}\n"
if defined $author;
foreach my $f (map {lc} keys %meta)
{ next if $meta{$f} eq ''; # empty is skipped.
push @lines,
'{MMCH_tail}\n";
}
foreach my $f ($self->selectedFields($head))
{ next if exists $meta{$f->name};
push @lines,
'{MMCH_tail}\n";
}
push @lines, "\n";
wantarray ? @lines : join('',@lines);
}
my $atom = qr/[^()<>@,;:\\".\[\]\s[:cntrl:]]+/;
my $email_address = qr/(($atom(?:\.$atom)*)\@($atom(?:\.$atom)+))/o;
sub fieldContentsToHtml($;$)
{ my ($self, $field, $subj) = @_;
my $subject = defined $subj ? '?subject='.$self->textToHtml($subj) : '';
my $body = $self->textToHtml($field->body);
my $comment = $field->comment;
$body =~ s#$email_address#$1#gx
if $field->name =~ m/^(resent-)?(to|from|cc|bcc|reply\-to)$/;
$body . ($comment ? '; '.$self->textToHtml($comment) : '');
}
1;
Mail-Message-4.05/lib/Mail/Message/Convert/Html.pod 0000644 0001750 0000144 00000012672 15166136117 022507 0 ustar 00markov users 0000000 0000000 =encoding utf8
=head1 NAME
Mail::Message::Convert::Html - Format messages in HTML
=head1 INHERITANCE
Mail::Message::Convert::Html
is a Mail::Message::Convert
is a Mail::Reporter
=head1 SYNOPSIS
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);
=head1 DESCRIPTION
The package contains various translators which handle HTML or XHTML
without the help of external modules. There are more HTML related modules,
which do require extra packages to be installed.
Extends L<"DESCRIPTION" in Mail::Message::Convert|Mail::Message::Convert/"DESCRIPTION">.
=head1 METHODS
Extends L<"METHODS" in Mail::Message::Convert|Mail::Message::Convert/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Mail::Message::Convert|Mail::Message::Convert/"Constructors">.
=over 4
=item $class-EB(%options)
Inherited, see L
-Option --Defined in --Default
fields Mail::Message::Convert
head_mailto true
produce HTML
=over 2
=item fields => $name|$regex|\@names|\@regexes
=item head_mailto => BOOLEAN
Whether to replace e-mail addresses in some header lines with links.
=item produce => 'HTML'|'XHTML'
Produce HTML or XHTML output. The output is slightly different, even
html browsers will usually accept the XHTML data.
=back
=back
=head2 Attributes
Extends L<"Attributes" in Mail::Message::Convert|Mail::Message::Convert/"Attributes">.
=head2 Converting
Extends L<"Converting" in Mail::Message::Convert|Mail::Message::Convert/"Converting">.
=over 4
=item $obj-EB( $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 C anchor. The C<$subject> can be specified to
be included in that link.
=item $obj-EB( $field, [$subject] )
Reformat one header line field to HTML. The C<$field>'s name
is printed in bold, followed by the formatted field content,
which is produced by L.
=item $obj-EB($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 C field will become the C,
and C is used for the C.
Besides, you can specify your own meta fields, which will overrule header
fields. Empty fields will not be included. When a C is specified,
this will become the html title, otherwise the C 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.
» example:
my @head = $html->headToHtmlHead(
$head,
description => 'This is a message',
generator => 'Mail::Box',
);
splice @head, -1, 0, '';
print @head;
=item $obj-EB( $head, [$table_params] )
Produce a display of the L of the header in a
table shape. The optional C<$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%"');
=item $obj-EB($head)
Inherited, see L
=item $obj-EB($lines)
Translate one or more C<$lines> from text into HTML. Each line is taken one
after the other, and only simple things are translated. C
is able to convert large plain texts in a descent fashion. In scalar
context, the resulting lines are returned as one.
=back
=head2 Error handling
Extends L<"Error handling" in Mail::Message::Convert|Mail::Message::Convert/"Error handling">.
=over 4
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=back
=head2 Cleanup
Extends L<"Cleanup" in Mail::Message::Convert|Mail::Message::Convert/"Cleanup">.
=over 4
=item $obj-EB()
Inherited, see L
=back
=head1 DIAGNOSTICS
=over 4
=item Error: class $package does not implement method $method.
Fatal error: the specific C<$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 C
=item Error: produce XHTML or HTML, not $what.
Cast by C
=back
=head1 SEE ALSO
This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F
=head1 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.
Mail-Message-4.05/lib/Mail/Message/Convert/TextAutoformat.pod 0000644 0001750 0000144 00000006110 15166136117 024557 0 ustar 00markov users 0000000 0000000 =encoding utf8
=head1 NAME
Mail::Message::Convert::TextAutoformat - Reformat plain text messages
=head1 INHERITANCE
Mail::Message::Convert::TextAutoformat
is a Mail::Message::Convert
is a Mail::Reporter
=head1 SYNOPSIS
use Mail::Message::Convert::TextAutoformat;
my $af = Mail::Message::Convert::TextAutoformat->new;
my $beautified_body = $af->autoformatBody($body);
=head1 DESCRIPTION
Play trics with plain text, for instance bodies with type C
using Damian Conway's Text::Autoformat.
Extends L<"DESCRIPTION" in Mail::Message::Convert|Mail::Message::Convert/"DESCRIPTION">.
=head1 METHODS
Extends L<"METHODS" in Mail::Message::Convert|Mail::Message::Convert/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Mail::Message::Convert|Mail::Message::Convert/"Constructors">.
=over 4
=item $class-EB(%options)
Inherited, see L
-Option --Defined in --Default
fields Mail::Message::Convert
options +{ all => 1 }
=over 2
=item fields => $name|$regex|\@names|\@regexes
=item options => \%af
The C<%af> options to pass to Text::Autoformat function C.
=back
=back
=head2 Attributes
Extends L<"Attributes" in Mail::Message::Convert|Mail::Message::Convert/"Attributes">.
=head2 Converting
Extends L<"Converting" in Mail::Message::Convert|Mail::Message::Convert/"Converting">.
=over 4
=item $obj-EB($body)
Formats a single message body (a L object) into a new
body object using Text::Autoformat.
The body should have content type C, otherwise the output is
probably weird.
=item $obj-EB($head)
Inherited, see L
=back
=head2 Error handling
Extends L<"Error handling" in Mail::Message::Convert|Mail::Message::Convert/"Error handling">.
=over 4
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=back
=head2 Cleanup
Extends L<"Cleanup" in Mail::Message::Convert|Mail::Message::Convert/"Cleanup">.
=over 4
=item $obj-EB()
Inherited, see L
=back
=head1 DIAGNOSTICS
=over 4
=item Error: class $package does not implement method $method.
Fatal error: the specific C<$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 C
=back
=head1 SEE ALSO
This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F
=head1 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.
Mail-Message-4.05/lib/Mail/Message/Convert/HtmlFormatPS.pod 0000644 0001750 0000144 00000006040 15166136117 024113 0 ustar 00markov users 0000000 0000000 =encoding utf8
=head1 NAME
Mail::Message::Convert::HtmlFormatPS - Convert HTML into PostScript
=head1 INHERITANCE
Mail::Message::Convert::HtmlFormatPS
is a Mail::Message::Convert
is a Mail::Reporter
=head1 SYNOPSIS
use Mail::Message::Convert::HtmlFormatPS;
my $af = Mail::Message::Convert::HtmlFormatPS->new;
my $postscript = $af->format($body);
=head1 DESCRIPTION
Translate an HTML/XHTML message body into a postscript body
using HTML::FormatPS.
Extends L<"DESCRIPTION" in Mail::Message::Convert|Mail::Message::Convert/"DESCRIPTION">.
=head1 METHODS
Extends L<"METHODS" in Mail::Message::Convert|Mail::Message::Convert/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Mail::Message::Convert|Mail::Message::Convert/"Constructors">.
=over 4
=item $class-EB(%options)
C<%options> which start with capitals are blindly passed to HTML::FormatPS.
As of this writing, that package defines BottomMargin, FontFamily,
FontScale, HorizontalMargin, Leading, LeftMargin, PageNo, PaperHeight,
PaperSize, PaperWidth, RightMargin, TopMargin, and VerticalMargin.
Improves base, see L
-Option--Defined in --Default
fields Mail::Message::Convert
=over 2
=item fields => $name|$regex|\@names|\@regexes
=back
=back
=head2 Attributes
Extends L<"Attributes" in Mail::Message::Convert|Mail::Message::Convert/"Attributes">.
=head2 Converting
Extends L<"Converting" in Mail::Message::Convert|Mail::Message::Convert/"Converting">.
=over 4
=item $obj-EB($body)
Pass an html or xhtml encoded body, and a plain text body is returned.
Characters are translated into Latin1.
=item $obj-EB($head)
Inherited, see L
=back
=head2 Error handling
Extends L<"Error handling" in Mail::Message::Convert|Mail::Message::Convert/"Error handling">.
=over 4
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=back
=head2 Cleanup
Extends L<"Cleanup" in Mail::Message::Convert|Mail::Message::Convert/"Cleanup">.
=over 4
=item $obj-EB()
Inherited, see L
=back
=head1 DIAGNOSTICS
=over 4
=item Error: class $package does not implement method $method.
Fatal error: the specific C<$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 C
=back
=head1 SEE ALSO
This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F
=head1 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.
Mail-Message-4.05/lib/Mail/Message/Convert/HtmlFormatText.pod 0000644 0001750 0000144 00000006542 15166136117 024524 0 ustar 00markov users 0000000 0000000 =encoding utf8
=head1 NAME
Mail::Message::Convert::HtmlFormatText - Convert HTML into Text
=head1 INHERITANCE
Mail::Message::Convert::HtmlFormatText
is a Mail::Message::Convert
is a Mail::Reporter
=head1 SYNOPSIS
use Mail::Message::Convert::HtmlFormatText;
my $af = Mail::Message::Convert::HtmlFormatText->new;
my $plain_body = $af->format($body);
=head1 DESCRIPTION
Convert HTML/XHTML message body objects into plain text bodies using
HTML::FormatText. This package requires HTML::TreeBuilder and
HTML::FormatText which are not installed by default together with
L. See also L with rule
C.
This module is a small wrapper around HTML::FormatText.
Extends L<"DESCRIPTION" in Mail::Message::Convert|Mail::Message::Convert/"DESCRIPTION">.
=head1 METHODS
Extends L<"METHODS" in Mail::Message::Convert|Mail::Message::Convert/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Mail::Message::Convert|Mail::Message::Convert/"Constructors">.
=over 4
=item $class-EB(%options)
Inherited, see L
-Option --Defined in --Default
fields Mail::Message::Convert
leftmargin 3
rightmargin 72
=over 2
=item fields => $name|$regex|\@names|\@regexes
=item leftmargin => INTEGER
The column of the left margin, passed to the formatter.
=item rightmargin => INTEGER
The column of the right margin, passed to the formatter.
=back
=back
=head2 Attributes
Extends L<"Attributes" in Mail::Message::Convert|Mail::Message::Convert/"Attributes">.
=head2 Converting
Extends L<"Converting" in Mail::Message::Convert|Mail::Message::Convert/"Converting">.
=over 4
=item $obj-EB($body)
Pass an html/xhtml encoded body, and a plain text body is returned.
Characters are translated into Latin1.
=item $obj-EB($head)
Inherited, see L
=back
=head2 Error handling
Extends L<"Error handling" in Mail::Message::Convert|Mail::Message::Convert/"Error handling">.
=over 4
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=back
=head2 Cleanup
Extends L<"Cleanup" in Mail::Message::Convert|Mail::Message::Convert/"Cleanup">.
=over 4
=item $obj-EB()
Inherited, see L
=back
=head1 DIAGNOSTICS
=over 4
=item Error: class $package does not implement method $method.
Fatal error: the specific C<$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 C
=back
=head1 SEE ALSO
This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F
=head1 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.
Mail-Message-4.05/lib/Mail/Message/Convert/MimeEntity.pod 0000644 0001750 0000144 00000010353 15166136117 023661 0 ustar 00markov users 0000000 0000000 =encoding utf8
=head1 NAME
Mail::Message::Convert::MimeEntity - translate Mail::Message to MIME::Entity vv
=head1 INHERITANCE
Mail::Message::Convert::MimeEntity
is a Mail::Message::Convert
is a Mail::Reporter
=head1 SYNOPSIS
use Mail::Message::Convert::MimeEntity;
my $convert = Mail::Message::Convert::MimeEntity->new;
my Mail::Message $msg = Mail::Message->new;
my MIME::Entity $entity = $convert->export($msg);
my MIME::Entity $entity = MIME::Entity->new;
my Mail::Message $msg = $convert->from($entity);
use Mail::Box::Manager;
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open(folder => 'Outbox');
$folder->addMessage($entity);
=head1 DESCRIPTION
The MIME::Entity extends L message with multiparts
and more methods. The L objects are more flexible
in how the message parts are stored, and uses separate header and body
objects.
Extends L<"DESCRIPTION" in Mail::Message::Convert|Mail::Message::Convert/"DESCRIPTION">.
=head1 METHODS
Extends L<"METHODS" in Mail::Message::Convert|Mail::Message::Convert/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Mail::Message::Convert|Mail::Message::Convert/"Constructors">.
=over 4
=item $class-EB(%options)
Inherited, see L
=back
=head2 Attributes
Extends L<"Attributes" in Mail::Message::Convert|Mail::Message::Convert/"Attributes">.
=head2 Converting
Extends L<"Converting" in Mail::Message::Convert|Mail::Message::Convert/"Converting">.
=over 4
=item $obj-EB( $message, [$parser] )
Returns a new MIME::Entity message object based on the
information from the C<$message>, which is a L object.
You may want to supply your own C<$parser>, which is a MIME::Parser
object, to change the parser flags. Without a C<$parser> object, one
is created for you, with all the default settings.
If C is passed, in place of a C<$message>, then an empty list is
returned. When the parsing failes, then MIME::Parser throws an
exception.
» example:
my $convert = Mail::Message::Convert::MimeEntity->new;
my Mail::Message $msg = Mail::Message->new;
my MIME::Entity $copy = $convert->export($msg);
=item $obj-EB($mime_object)
Returns a new L object based on the information from
the specified MIME::Entity. If the conversion fails, the C
is returned. If C is passed in place of an OBJECT, then an
empty list is returned.
» example:
my $convert = Mail::Message::Convert::MimeEntity->new;
my MIME::Entity $msg = MIME::Entity->new;
my Mail::Message $copy = $convert->from($msg);
=item $obj-EB($head)
Inherited, see L
=back
=head2 Error handling
Extends L<"Error handling" in Mail::Message::Convert|Mail::Message::Convert/"Error handling">.
=over 4
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=back
=head2 Cleanup
Extends L<"Cleanup" in Mail::Message::Convert|Mail::Message::Convert/"Cleanup">.
=over 4
=item $obj-EB()
Inherited, see L
=back
=head1 DIAGNOSTICS
=over 4
=item Error: class $package does not implement method $method.
Fatal error: the specific C<$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 C
=item Error: converting from MIME::Entity but got a $class.
Cast by C
=item Error: export message must be a Mail::Message object, but is $what.
Cast by C
=back
=head1 SEE ALSO
This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F
=head1 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.
Mail-Message-4.05/lib/Mail/Message/Convert/EmailSimple.pm 0000644 0001750 0000144 00000002410 15166136116 023622 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Convert::EmailSimple;{
our $VERSION = '4.05';
}
use parent 'Mail::Message::Convert';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw/__x error/ ];
use Mail::Internet ();
use Mail::Header ();
use Email::Simple ();
use Mail::Message ();
use Mail::Message::Head::Complete ();
use Mail::Message::Body::Lines ();
#--------------------
sub export($@)
{ my ($thing, $message) = @_;
$message->isa('Mail::Message')
or error __x"export message must be a Mail::Message, but is a {class}.", class => ref $message;
Email::Simple->new($message->string);
}
sub from($@)
{ my ($thing, $email) = (shift, shift);
$email->isa('Email::Simple')
or error __x"converting from Email::Simple but got a {class}.", class => ref $email;
Mail::Message->read($email->as_string);
}
1;
Mail-Message-4.05/lib/Mail/Message/Convert/MailInternet.pm 0000644 0001750 0000144 00000003756 15166136116 024032 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Convert::MailInternet;{
our $VERSION = '4.05';
}
use parent 'Mail::Message::Convert';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw/__x error/ ];
use Mail::Internet ();
use Mail::Header ();
use Mail::Message ();
use Mail::Message::Head::Complete ();
use Mail::Message::Body::Lines ();
#--------------------
sub export($@)
{ my ($thing, $message) = (shift, shift);
$message->isa('Mail::Message')
or error __x"export message must be a Mail::Message object, but is {what UNKNOWN}.", what => $message;
my $mi_head = Mail::Header->new;
foreach my $field ($message->head->orderedFields)
{ $mi_head->add($field->Name, scalar $field->foldedBody);
}
Mail::Internet->new(Header => $mi_head, Body => [ $message->body->lines ], @_);
}
my @pref_order = qw/From To Cc Subject Date In-Reply-To References Content-Type/;
sub from($@)
{ my ($thing, $mi) = (shift, shift);
$mi->isa('Mail::Internet')
or error __x"converting from Mail::Internet but got {what UNKNOWN}.", what => $mi;
my $head = Mail::Message::Head::Complete->new;
my $body = Mail::Message::Body::Lines->new(data => [ @{$mi->body} ]);
my $mi_head = $mi->head;
# The tags of Mail::Header are unordered, but we prefer some ordering.
my %tags = map +(lc $_ => ucfirst $_), $mi_head->tags;
my @tags;
foreach (@pref_order)
{ push @tags, $_ if delete $tags{lc $_};
}
push @tags, sort values %tags;
foreach my $name (@tags)
{ $head->add($name, $_) for $mi_head->get($name);
}
Mail::Message->new(head => $head, body => $body, @_);
}
1;
Mail-Message-4.05/lib/Mail/Message/Convert/MailInternet.pod 0000644 0001750 0000144 00000007645 15166136117 024202 0 ustar 00markov users 0000000 0000000 =encoding utf8
=head1 NAME
Mail::Message::Convert::MailInternet - translate Mail::Message to Mail::Internet vv
=head1 INHERITANCE
Mail::Message::Convert::MailInternet
is a Mail::Message::Convert
is a Mail::Reporter
=head1 SYNOPSIS
use Mail::Message::Convert::MailInternet;
my $convert = Mail::Message::Convert::MailInternet->new;
my Mail::Message $msg = Mail::Message->new;
my Mail::Internet $intern = $convert->export($msg);
my Mail::Internet $intern = Mail::Internet->new;
my Mail::Message $msg = $convert->from($intern);
use Mail::Box::Manager;
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open(folder => 'Outbox');
$folder->addMessage($intern);
=head1 DESCRIPTION
The L class of messages is very popular for all
kinds of message applications written in Perl. However, the
format was developed when e-mail messages where still small and
attachments where rare; L is much more flexible in
this respect.
Extends L<"DESCRIPTION" in Mail::Message::Convert|Mail::Message::Convert/"DESCRIPTION">.
=head1 METHODS
Extends L<"METHODS" in Mail::Message::Convert|Mail::Message::Convert/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Mail::Message::Convert|Mail::Message::Convert/"Constructors">.
=over 4
=item $class-EB(%options)
Inherited, see L
=back
=head2 Attributes
Extends L<"Attributes" in Mail::Message::Convert|Mail::Message::Convert/"Attributes">.
=head2 Converting
Extends L<"Converting" in Mail::Message::Convert|Mail::Message::Convert/"Converting">.
=over 4
=item $obj-EB($message, %options)
Returns a new message object based on the information from
a L object. The C<$message> specified is an
instance of a L.
» example:
my $convert = Mail::Message::Convert::MailInternet->new;
my Mail::Message $msg = Mail::Message->new;
my Mail::Internet $copy = $convert->export($msg);
=item $obj-EB($object, %options)
Returns a new L object based on the information
from a L object.
» example:
my $convert = Mail::Message::Convert::MailInternet->new;
my Mail::Internet $msg = Mail::Internet->new;
my Mail::Message $copy = $convert->from($msg);
=item $obj-EB($head)
Inherited, see L
=back
=head2 Error handling
Extends L<"Error handling" in Mail::Message::Convert|Mail::Message::Convert/"Error handling">.
=over 4
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=back
=head2 Cleanup
Extends L<"Cleanup" in Mail::Message::Convert|Mail::Message::Convert/"Cleanup">.
=over 4
=item $obj-EB()
Inherited, see L
=back
=head1 DIAGNOSTICS
=over 4
=item Error: class $package does not implement method $method.
Fatal error: the specific C<$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 C
=item Error: converting from Mail::Internet but got a $what.
Cast by C
=item Error: export message must be a Mail::Message object, but is $what.
Cast by C
=back
=head1 SEE ALSO
This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F
=head1 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.
Mail-Message-4.05/lib/Mail/Message/Convert/EmailSimple.pod 0000644 0001750 0000144 00000010034 15166136117 023772 0 ustar 00markov users 0000000 0000000 =encoding utf8
=head1 NAME
Mail::Message::Convert::EmailSimple - translate Mail::Message to Email::Simple vv
=head1 INHERITANCE
Mail::Message::Convert::EmailSimple
is a Mail::Message::Convert
is a Mail::Reporter
=head1 SYNOPSIS
use Mail::Message::Convert::EmailSimple;
my $convert = Mail::Message::Convert::EmailSimple->new;
my Mail::Message $msg = Mail::Message->new;
my Email::Simple $intern = $convert->export($msg);
my Email::Simple $intern = Mail::Internet->new;
my Mail::Message $msg = $convert->from($intern);
use Mail::Box::Manager;
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open(folder => 'Outbox');
$folder->addMessage($intern);
=head1 DESCRIPTION
The Email::Simple class is one of the base objects used by the
large set of Email* modules, which implement many e-mail needs
which are also supported by MailBox. You can use this class to
gradularly move from a Email* based implementation into a MailBox
implementation.
The internals of this class are far from optimal. The conversion
does work (thanks to Ricardo Signes), but is expensive in time
and memory usage. It could easily be optimized.
Extends L<"DESCRIPTION" in Mail::Message::Convert|Mail::Message::Convert/"DESCRIPTION">.
=head1 METHODS
Extends L<"METHODS" in Mail::Message::Convert|Mail::Message::Convert/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Mail::Message::Convert|Mail::Message::Convert/"Constructors">.
=over 4
=item $class-EB(%options)
Inherited, see L
=back
=head2 Attributes
Extends L<"Attributes" in Mail::Message::Convert|Mail::Message::Convert/"Attributes">.
=head2 Converting
Extends L<"Converting" in Mail::Message::Convert|Mail::Message::Convert/"Converting">.
=over 4
=item $obj-EB($message, %options)
Returns a new Email::Simple object based on the information from
a L object. The C<$message> specified is an
instance of a L.
» example:
my $convert = Mail::Message::Convert::EmailSimple->new;
my Mail::Message $msg = Mail::Message->new;
my Mail::Internet $copy = $convert->export($msg);
=item $obj-EB($object, %options)
Returns a new L object based on the information from
an Email::Simple.
» example:
my $convert = Mail::Message::Convert::EmailSimple->new;
my Mail::Internet $msg = Mail::Internet->new;
my Mail::Message $copy = $convert->from($msg);
=item $obj-EB($head)
Inherited, see L
=back
=head2 Error handling
Extends L<"Error handling" in Mail::Message::Convert|Mail::Message::Convert/"Error handling">.
=over 4
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=back
=head2 Cleanup
Extends L<"Cleanup" in Mail::Message::Convert|Mail::Message::Convert/"Cleanup">.
=over 4
=item $obj-EB()
Inherited, see L
=back
=head1 DIAGNOSTICS
=over 4
=item Error: class $package does not implement method $method.
Fatal error: the specific C<$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 C
=item Error: converting from Email::Simple but got a $class.
Cast by C
=item Error: export message must be a Mail::Message, but is a $class.
Cast by C
=back
=head1 SEE ALSO
This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F
=head1 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.
Mail-Message-4.05/lib/Mail/Message/Convert/HtmlFormatText.pm 0000644 0001750 0000144 00000002444 15166136116 024352 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Convert::HtmlFormatText;{
our $VERSION = '4.05';
}
use parent 'Mail::Message::Convert';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw// ];
use HTML::TreeBuilder ();
use HTML::FormatText ();
use Mail::Message::Body::String ();
#--------------------
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{MMCH_formatter} = HTML::FormatText->new(
leftmargin => $args->{leftmargin} // 3,,
rightmargin => $args->{rightmargin} // 72,
);
$self;
}
#--------------------
sub format($)
{ my ($self, $body) = @_;
my $dec = $body->encode(transfer_encoding => 'none');
my $tree = HTML::TreeBuilder->new_from_file($dec->file);
(ref $body)->new(
based_on => $body,
mime_type => 'text/plain',
charset => 'iso-8859-1',
data => [ $self->{MMCH_formatter}->format($tree) ],
);
}
1;
Mail-Message-4.05/lib/Mail/Message/Convert/MimeEntity.pm 0000644 0001750 0000144 00000002372 15166136116 023514 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Convert::MimeEntity;{
our $VERSION = '4.05';
}
use parent 'Mail::Message::Convert';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw/__x error/ ];
use MIME::Entity ();
use MIME::Parser ();
use Mail::Message ();
#--------------------
sub export($$;$)
{ my ($self, $message, $parser) = @_;
defined $message or return ();
$message->isa('Mail::Message')
or error __x"export message must be a Mail::Message object, but is {what UNKNOWN}.", what => $message;
$parser ||= MIME::Parser->new;
$parser->parse($message->file);
}
sub from($)
{ my ($self, $mime_ent) = @_;
defined $mime_ent or return ();
$mime_ent->isa('MIME::Entity')
or error __x"converting from MIME::Entity but got a {class}.", class => ref $mime_ent;
Mail::Message->read($mime_ent->as_string);
}
1;
Mail-Message-4.05/lib/Mail/Message/Convert/TextAutoformat.pm 0000644 0001750 0000144 00000002025 15166136116 024411 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Convert::TextAutoformat;{
our $VERSION = '4.05';
}
use parent 'Mail::Message::Convert';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw// ];
use Text::Autoformat qw/autoformat/;
use Mail::Message::Body::String ();
#--------------------
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{MMCA_options} = $args->{autoformat} || +{ all => 1 };
$self;
}
#--------------------
sub autoformatBody($)
{ my ($self, $body) = @_;
(ref $body)->new(based_on => $body, data => autoformat($body->string, $self->{MMCA_options}));
}
1;
Mail-Message-4.05/lib/Mail/Message/Convert/HtmlFormatPS.pm 0000644 0001750 0000144 00000002411 15166136116 023742 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Convert::HtmlFormatPS;{
our $VERSION = '4.05';
}
use parent 'Mail::Message::Convert';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw// ];
use Mail::Message::Body::String ();
use HTML::TreeBuilder ();
use HTML::FormatPS ();
#--------------------
sub init($)
{ my ($self, $args) = @_;
my @formopts = map +($_ => delete $args->{$_}), grep m/^[A-Z]/, keys %$args;
$self->SUPER::init($args);
$self->{MMCH_formatter} = HTML::FormatPS->new(@formopts);
$self;
}
#--------------------
sub format($)
{ my ($self, $body) = @_;
my $dec = $body->encode(transfer_encoding => 'none');
my $tree = HTML::TreeBuilder->new_from_file($dec->file);
(ref $body)->new(
based_on => $body,
mime_type => 'application/postscript',
data => [ $self->{MMCH_formatter}->format($tree) ],
);
}
1;
Mail-Message-4.05/lib/Mail/Message/Field/ 0000755 0001750 0000144 00000000000 15166136132 020467 5 ustar 00markov users 0000000 0000000 Mail-Message-4.05/lib/Mail/Message/Field/Address.pm 0000644 0001750 0000144 00000004063 15166136116 022417 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Field::Address;{
our $VERSION = '4.05';
}
use parent 'Mail::Identity';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw/__x error/ ];
use Mail::Message::Field::Addresses ();
use Mail::Message::Field::Full ();
use Scalar::Util qw/blessed/;
my $format = 'Mail::Message::Field::Full';
#--------------------
use overload
'""' => 'string',
bool => sub {1},
cmp => sub { lc($_[0]->address) cmp lc($_[1]) };
#--------------------
sub coerce($@)
{ my ($class, $addr, %args) = @_;
defined $addr or return ();
blessed $addr or return $class->parse($addr);
$addr->isa($class) and return $addr;
my $from = $class->from($addr, %args)
or error __x"cannot coerce a {type} into a {class}.", type => ref $addr // $addr, class => $class;
bless $from, $class;
}
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{MMFA_encoding} = delete $args->{encoding};
$self;
}
sub parse($)
{ my $self = shift;
my $parsed = Mail::Message::Field::Addresses->new(To => shift);
defined $parsed ? ($parsed->addresses)[0] : ();
}
#--------------------
sub encoding() { $_[0]->{MMFA_encoding} }
#--------------------
sub string()
{ my $self = shift;
my @opts = (charset => $self->charset, encoding => $self->encoding);
# language => $self->language
my @parts;
my $phrase = $self->phrase;
push @parts, $format->createPhrase($phrase, @opts) if defined $phrase;
my $address = $self->address;
push @parts, @parts ? '<'.$address.'>' : $address;
my $comment = $self->comment;
push @parts, $format->createComment($comment, @opts) if defined $comment;
join ' ', @parts;
}
1;
Mail-Message-4.05/lib/Mail/Message/Field/Unstructured.pm 0000644 0001750 0000144 00000002067 15166136117 023544 0 ustar 00markov users 0000000 0000000 # This code is part of Perl distribution Mail-Message version 4.05.
# The POD got stripped from this file by OODoc version 3.06.
# 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.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Mail::Message::Field::Unstructured;{
our $VERSION = '4.05';
}
use parent 'Mail::Message::Field::Full';
use strict;
use warnings;
use Log::Report 'mail-message', import => [ qw/__x warning/ ];
#--------------------
sub init($)
{ my ($self, $args) = @_;
if($args->{body} && ($args->{encoding} || $args->{charset}))
{ $args->{body} = $self->encode($args->{body}, %$args);
}
$self->SUPER::init($args);
! defined $args->{attributes} or warning __x"attributes are not supported for unstructured fields.";
! defined $args->{extra} or warning __x"no extras for unstructured fields.";
$self;
}
#--------------------
1;
Mail-Message-4.05/lib/Mail/Message/Field/Date.pod 0000644 0001750 0000144 00000026157 15166136117 022066 0 ustar 00markov users 0000000 0000000 =encoding utf8
=head1 NAME
Mail::Message::Field::Date - message header field with uris
=head1 INHERITANCE
Mail::Message::Field::Date
is a Mail::Message::Field::Structured
is a Mail::Message::Field::Full
is a Mail::Message::Field
is a Mail::Reporter
=head1 SYNOPSIS
my $f = Mail::Message::Field->new(Date => time);
my $f = Mail::Message::Field::Date->new(Date => time);
my $date = $f->date; # cleaned-up and validated
my $time = $date->time; # converted to POSIX time
=head1 DESCRIPTION
Dates are a little more tricky than it should be: the formatting permits
a few constructs more than other RFCs use for timestamps. For instance,
a small subset of timezone abbreviations are permitted.
The studied date field will reformat the content into a standard
form.
Extends L<"DESCRIPTION" in Mail::Message::Field::Structured|Mail::Message::Field::Structured/"DESCRIPTION">.
=head1 OVERLOADED
Extends L<"OVERLOADED" in Mail::Message::Field::Structured|Mail::Message::Field::Structured/"OVERLOADED">.
=over 4
=item overload: B<""> stringification
Inherited, see L
=item overload: B<'""'> stringification
Inherited, see L
=item overload: B<'0+'> numification
Inherited, see L
=item overload: B<'<=>'> numeric comparison
Inherited, see L
=item overload: B boolean
Inherited, see L
=item overload: B string comparison
Inherited, see L
=back
=head1 METHODS
Extends L<"METHODS" in Mail::Message::Field::Structured|Mail::Message::Field::Structured/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Mail::Message::Field::Structured|Mail::Message::Field::Structured/"Constructors">.
=over 4
=item $obj-EB()
Inherited, see L
=item $class-EB($field, %options)
Inherited, see L
=item $class-EB($data)
Inherited, see L
-Option --Defined in --Default
attributes Mail::Message::Field::Structured
charset Mail::Message::Field::Full undef
datum Mail::Message::Field::Structured undef
encoding Mail::Message::Field::Full 'q'
force Mail::Message::Field::Full false
language Mail::Message::Field::Full undef
=over 2
=item attributes => \@attributes|\%attributes
=item charset => $charset
=item datum => $date
=item encoding => 'q'|'Q'|'b'|'B'
=item force => BOOLEAN
=item language => $language
=back
» example:
my $mmfd = 'Mail::Message::Field::Date';
my $f = $mmfd->new(Date => time);
=back
=head2 Attributes
Extends L<"Attributes" in Mail::Message::Field::Structured|Mail::Message::Field::Structured/"Attributes">.
=over 4
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=item $obj-EB( [$body] )
Inherited, see L
=item $obj-EB()
Inherited, see L
=item $obj-EB( [$body, [$wrap]] )
Inherited, see L
=item $obj-EB( [STRING] )
Inherited, see L
=back
=head2 The field
Extends L<"The field" in Mail::Message::Field::Structured|Mail::Message::Field::Structured/"The field">.
=over 4
=item $any-EB( [$name] )
Inherited, see L
=item $obj-EB()
Inherited, see L
=item $obj-EB()
Inherited, see L
=item $obj-EB( [$fh] )
Inherited, see L
=item $obj-EB()
Inherited, see L
=item $obj-EB( [$wrap] )
Inherited, see L
=item $obj-EB()
Inherited, see L
=back
=head2 Access to the body
Extends L<"Access to the body" in Mail::Message::Field::Structured|Mail::Message::Field::Structured/"Access to the body">.
=over 4
=item $obj-EB(%options)
Inherited, see L
=back
=head2 Access to the content
Extends L<"Access to the content" in Mail::Message::Field::Structured|Mail::Message::Field::Structured/"Access to the content">.
=over 4
=item $obj-EB(...)
Attributes are not supported for date fields.
=item $obj-EB()
Inherited, see L
=item $obj-EB