=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