Mail-Message-3.017/0000755000175000001440000000000015000476765014520 5ustar00markovusers00000000000000Mail-Message-3.017/lib/0000755000175000001440000000000015000476765015266 5ustar00markovusers00000000000000Mail-Message-3.017/lib/Mail/0000755000175000001440000000000015000476765016150 5ustar00markovusers00000000000000Mail-Message-3.017/lib/Mail/Message/0000755000175000001440000000000015000476765017534 5ustar00markovusers00000000000000Mail-Message-3.017/lib/Mail/Message/Replace/0000755000175000001440000000000015000476765021107 5ustar00markovusers00000000000000Mail-Message-3.017/lib/Mail/Message/Replace/MailHeader.pm0000644000175000001440000001001415000476751023427 0ustar00markovusers00000000000000# Copyrights 2001-2025 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.03. # This code is part of distribution Mail-Message. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Message::Replace::MailHeader;{ our $VERSION = '3.017'; } use base 'Mail::Message::Head::Complete'; use strict; use warnings; sub new(@) { my $class = shift; unshift @_, 'raw_data' if @_ % 2; $class->SUPER::new(@_); } sub init($) { my ($self, $args) = @_; defined $self->SUPER::init($args) or return; $self->modify ($args->{Modify} || $args->{Reformat} || 0); $self->fold_length($args->{FoldLength} || 79); $self->mail_from ($args->{MailFrom} || 'KEEP'); $self; } sub delete($;$) { my ($self, $tag) = (shift, shift); return $self->delete($tag) unless @_; my $index = shift; my @fields = $self->get($tag); my ($field) = splice @fields, $index, 1; $self->reset($tag, @fields); $field; } sub add($$) { my $self = shift; my $field = $self->add(shift); $field->unfoldedBody; } sub replace($$;$) { my ($self, $tag, $line, $index) = @_; $line =~ s/^([^:]+)\:\s*// && ($tag = $1) unless defined $tag; my $field = Mail::Message::Field::Fast->new($tag, $line); my @fields = $self->get($tag); $fields[ $index||0 ] = $field; $self->reset($tag, @fields); $field; } sub get($;$) { my $head = shift->head; my @ret = map { $head->get(@_) } @_; if(wantarray) { return @ret ? map({$_->unfoldedBody} @ret) : () } else { return @ret ? $ret[0]->unfoldedBody : undef } } sub modify(;$) { my $self = shift; @_ ? ($self->{MH_refold} = shift) : $self->{MH_refold}; } sub mail_from(;$) { my $self = shift; return $self->{MH_mail_from} unless @_; my $choice = uc(shift); die "bad Mail-From choice: '$choice'" unless $choice =~ /^(IGNORE|ERROR|COERCE|KEEP)$/; $self->{MH_mail_from} = $choice; } sub fold(;$) { my $self = shift; my $wrap = @_ ? shift : $self->fold_length; $_->setWrapLength($wrap) foreach $self->orderedFields; $self; } sub unfold(;$) { my $self = shift; my @fields = @_ ? $self->get(shift) : $self->orderedFields; $_->setWrapLength(100_000) foreach @fields; # blunt approach $self; } sub extract($) { my ($self, $lines) = @_; my $parser = Mail::Box::Parser::Perl->new ( filename => 'extract from array' , data => $lines , trusted => 1 ); $self->read($parser); $parser->close; # Remove header from array shift @$lines while @$lines && $lines->[0] != m/^[\r\n]+/; shift @$lines if @$lines; $self; } sub read($) { my ($self, $file) = @_; my $parser = Mail::Box::Parser::Perl->new ( filename => ('from file-handle '.ref $file) , file => $file , trusted => 1 ); $self->read($parser); $parser->close; $self; } sub empty() { shift->removeFields( m/^/ ) } sub header(;$) { my $self = shift; $self->extract(shift) if @_; $self->fold if $self->modify; [ $self->orderedFields ]; } sub header_hashref($) { die "Don't use header_hashref!!!" } sub combine($;$) { die "Don't use combine()!!!" } sub exists() { shift->count } sub as_string() { shift->string } sub fold_length(;$$) { my $self = shift; return $self->{MH_wrap} unless @_; my $old = $self->{MH_wrap}; my $wrap = $self->{MH_wrap} = shift; $self->fold($wrap) if $self->modify; $old; } sub tags() { shift->names } sub dup() { shift->clone } sub cleanup() { shift } BEGIN { no warnings; *Mail::Header::new = sub { my $class = shift; Mail::Message::Replace::MailHeader->new(@_); } } sub isa($) { my ($thing, $class) = @_; return 1 if $class eq 'Mail::Mailer'; $thing->SUPER::isa($class); } 1; Mail-Message-3.017/lib/Mail/Message/Replace/MailInternet.pod0000644000175000001440000006234715000476753024217 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Message::Replace::MailInternet - fake Mail::Internet =head1 INHERITANCE Mail::Message::Replace::MailInternet is a Mail::Message is a Mail::Reporter =head1 SYNOPSIS !!! BETA !!! # change use Mail::Internet; # into use Mail::Message::Replace::MailInternet; # in existing code, and the code should still work, but # with the Mail::Message features. =head1 DESCRIPTION This module is a wrapper around a L, which simulates a L object. The name-space of that module is hijacked and many methods are added. Most methods will work without any change, but you may need to have a look at your L and L calls. Extends L<"DESCRIPTION" in Mail::Message|Mail::Message/"DESCRIPTION">. =head1 OVERLOADED =head1 METHODS Extends L<"METHODS" in Mail::Message|Mail::Message/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Message|Mail::Message/"Constructors">. =over 4 =item $obj-EB(%options) Inherited, see L =item $obj-EB() Duplicate the message. The result will again be a L compatible object. =item $obj-EB() Remove all data from this object. Very dangerous! =item Mail::Message::Replace::MailInternet-EB( [$arg], [%options] ) -Option --Defined in --Default Body undef FoldLength 79 Header undef MailFrom 'KEEP' Modify 0 body Mail::Message undef body_type Mail::Message Mail::Message::Body::Lines deleted Mail::Message field_type Mail::Message undef head Mail::Message undef head_type Mail::Message Mail::Message::Replace::MailHeader labels Mail::Message {} log Mail::Reporter 'WARNINGS' messageId Mail::Message undef modified Mail::Message trace Mail::Reporter 'WARNINGS' trusted Mail::Message =over 2 =item Body => \@lines Array of C<"\n"> terminated lines. If not specified, the lines will be read from $arg. =item FoldLength => INTEGER Number of characters permitted on any refolded header line. Passed to L. =item Header => OBJECT The L object, which is passed here, is a fake one as well... It is translated into a L. If not given, the header will be parsed from the $arg. =item MailFrom => 'IGNORE'|'ERROR'|'COERCE'|'KEEP' What to do with leading "C" lines in e-mail data. Passed to L. =item Modify => BOOLEAN Whether to re-fold all the incoming fields. Passed to L. =item body => OBJECT =item body_type => CLASS =item deleted => BOOLEAN =item field_type => CLASS =item head => OBJECT =item head_type => CLASS =item labels => ARRAY|HASH =item log => LEVEL =item messageId => STRING =item modified => BOOLEAN =item trace => LEVEL =item trusted => BOOLEAN =back example: replace traditional Mail::Internet by this wrapper # was use Mail::Internet; my $mi = Mail::Internet->new(@options); # becomes use Mail::Message::Replace::MailInternet; my $mi = Mail::Internet->new(@options); =back =head2 Attributes =over 4 =item $obj-EB( [STRING] ) Your email address. =back =head2 Constructing a message Extends L<"Constructing a message" in Mail::Message|Mail::Message/"Constructing a message">. =over 4 =item $obj-EB( [$filename] ) Replaced by L, but still usable. $filename is the file which contains the signature, which defaults to C<$ENV{HOME}/.signature>. =item $obj-EB( [<$rg_object|%options>] ) Inherited, see L =item Mail::Message::Replace::MailInternet-EB( [$message|$part|$body], $content ) Inherited, see L =item Mail::Message::Replace::MailInternet-EB($body, [$head], $headers) Inherited, see L =item $obj-EB(\@lines|$fh) Read header and body from an ARRAY or $fh =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB(STRING) Inherited, see L =item $obj-EB(\@lines|$fh, %options) =item Mail::Message::Replace::MailInternet-EB(\@lines|$fh, %options) Read header and body from the specified ARRAY or $fh. When used as object method, L is called, to be MailBox compliant. As class method, the Mail::Internet compatible read is called. %options are only available in the first case. -Option --Defined in --Default body_type Mail::Message::Construct::Read undef strip_status_fields Mail::Message::Construct::Read =over 2 =item body_type => CLASS =item strip_status_fields => BOOLEAN =back =item $obj-EB(\@lines|$fh) Read only the message's body from the ARRAY or $fh. =item $obj-EB(\@lines|$fh) Read only the message's header from the ARRAY or $fh =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) BE WARNED: the main job for creating a reply is done by L, which may produce a result which is compatible, but may be different from L's version. -Option --Defined in --Default Bcc Mail::Message::Construct::Reply undef Cc Mail::Message::Construct::Reply <'cc' in current> Exclude [] From Mail::Message::Construct::Reply <'to' in current> Inline > Keep [] Message-ID Mail::Message::Construct::Reply ReplyAll Subject Mail::Message::Construct::Reply replySubject() To Mail::Message::Construct::Reply body Mail::Message::Construct::Reply undef group_reply Mail::Message::Construct::Reply header_template $ENV{HOME}/.mailhdr include Mail::Message::Construct::Reply 'INLINE' max_signature Mail::Message::Construct::Reply 10 message_type Mail::Message::Construct::Reply Mail::Message postlude Mail::Message::Construct::Reply undef prelude Mail::Message::Construct::Reply undef quote Mail::Message::Construct::Reply '> ' signature Mail::Message::Construct::Reply undef strip_signature Mail::Message::Construct::Reply qr/^--\s/ =over 2 =item Bcc => ADDRESSES =item Cc => ADDRESSES =item Exclude => \@names Remove the fields with the specified names from the produced reply message. =item From => ADDRESSES =item Inline => STRING Quotation STRING, which is translated into L. The normal default of C is "E ", in stead of "E". =item Keep => \@names Copy all header fields with the specified NAMES from the source to the reply message. =item Message-ID => STRING =item ReplyAll => BOOLEAN Reply to the group? Translated into L, which has as default the exact oposite of this option, being C. =item Subject => STRING|CODE =item To => ADDRESSES =item body => BODY =item group_reply => BOOLEAN =item header_template => $filename|C Read the return header from the template file. When this is explicitly set to C, or the file does not exist, then a header will be created. =item include => 'NO'|'INLINE'|'ATTACH' =item max_signature => INTEGER =item message_type => CLASS =item postlude => BODY|LINES =item prelude => BODY|LINES =item quote => CODE|STRING =item signature => BODY|MESSAGE =item strip_signature => REGEXP|STRING|CODE =back =item $obj-EB( [STRING|$field|$address|ARRAY-$of-$things] ) Inherited, see L =item $obj-EB(STRING) =item Mail::Message::Replace::MailInternet-EB(STRING) Inherited, see L =item $obj-EB(%options) Add a signature (a few extra lines) to the message. -Option --Default File undef Signature '' =over 2 =item File => $filename Specifies a filename where the signature is in. =item Signature => STRING|\@lines The signature in memory. =back =back =head2 The message Extends L<"The message" in Mail::Message|Mail::Message/"The message">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB(%options) Send an NNTP message (newsgroup message), which is equivalent to Mail::Transport::NNTP or L with C. -Option--Default Debug Host Port 119 =over 2 =item Debug => BOOLEAN =item Host => $hostname =item Port => INTEGER =back =item $obj-EB() Inherited, see L =item $obj-EB( [$fh] ) Prints the whole message to the specified $fh, which default to STDOUT. This calls L. =item $obj-EB($type, %options) Send via Mail Transfer Agents (MUA). These will be handled by various L extensions. The C $type is not supported. =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$fh] ) Inherited, see L =back =head2 The header Extends L<"The header" in Mail::Message|Mail::Message/"The header">. =over 4 =item $obj-EB(\@lines) Add header lines, which simply calls C on the header for each specified LINE. The last added LINE is returned. =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Not to be used, replaced by L. =item $obj-EB( $tag, [$with] ) Not implemented, because I see no use for it. =item $obj-EB() Inherited, see L =item $obj-EB( $name, [$index]] ) Delete the fields with the specified $name. The deleted fields are returned. BE WARNED: if no $name is specified, the C is interpreted as the deletion of the message in a folder, so L will be called. This may have no negative effect at all... Calls L =item $obj-EB() Inherited, see L =item $obj-EB( [$length] ) Fold all the fields to a certain maximum $length. Implemented by L =item $obj-EB( [[$tag], $length] ) Set the maximum line $length. $tag is ignored. Implemented by L =item $obj-EB() Inherited, see L =item $obj-EB( $name, [$index] ) Get all the header fields with the specified $name. In scalar context, only the first fitting $name is returned. Even when only one $name is specified, multiple lines may be returned: some fields appear more than once in a header. Calls L =item $obj-EB() Inherited, see L =item $obj-EB( [$head] ) Returns the head of the message, or creates an empty one if none is defined. The $head argument, which sets the header, is not available for L, but is there to be compatible with the C method of L. =item $obj-EB
( [\@lines] ) Optionally reads a header from the ARRAY of lines, and then returns those fields as array-ref nicely folded. Implemented by L =item $obj-EB() Inherited, see L =item $obj-EB($fh) Calls L. =item $obj-EB( $tag, $line, [$index] ) Adds LINES to the header, but removes fields with the same name if they already exist. Calls L =item $obj-EB() Inherited, see L =item $obj-EB($fieldname) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() No effect anymore (always performed). =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 The body Extends L<"The body" in Mail::Message|Mail::Message/"The body">. =over 4 =item $obj-EB($lines|@lines) Returns an ARRAY of lines, representing the body. With arguments, a new body will be created. In L, the body is not an object but a simple array. BE WARNED: this overrules the L method, which may cause some confusion. Use L to get access to that body's data. =item $obj-EB( [$body] ) Calls L, because that C method is overruled by the one which has a L compatible interface. =item $obj-EB() Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [<'ALL'|'ACTIVE'|'DELETED'|'RECURSE'|$filter>] ) Inherited, see L =item $obj-EB( [$fh] ) Prints the body to the specified $fh, which defaults to STDOUT. This calls L. =item $obj-EB( [$nrlines] ) Remove the signature of a message with a maximum of $nrlines lines, which defaults to 10. The work is done on the decoded body content, by L. =item $obj-EB(%options) This method is calling L via C, which is implemented in L. The implementation is slightly different, so this method is not 100% compliant. -Option --Default Debug Hello Host $ENV{SMTPHOSTS} or from Net::Config MailFrom $ENV{MAILADDRESS} or $ENV{USER} Port 25 =over 2 =item Debug => BOOLEAN =item Hello => STRING =item Host => HOSTNAME Only the first detected HOSTNAME is taken, so differs from the original implementation. =item MailFrom => STRING Your e-mail address. This simulated L object does not try to create an e-mail address from the sendmail configuration file, because that is generally a bad idea in environments with virtual hosts, as we have now-adays. =item Port => INTEGER =back =item $obj-EB() Removes blank lines from begin and end of the body. =back =head2 Flags Extends L<"Flags" in Mail::Message|Mail::Message/"Flags">. =over 4 =item $obj-EB( [BOOLEAN] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB