Mail::Message::Replace::MailInternet3pm
Fake mail::internet
Usage
# changeuse Mail::Internet;# intouse Mail::Message::Replace::MailInternet;# in existing code, and the code should still work, but# with the Mail::Message features.
Inheritance
Mail::Message::Replace::MailInternetis a Mail::Messageis a Mail::Reporter
Overview
This module is a wrapper around a Mail::Message, which simulates a Mail::Internet 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 smtpsend() and send() calls.
Extends "DESCRIPTION" in Mail::Message.
Overloaded
Methods
Extends "METHODS" in Mail::Message.
Constructors
Extends "Constructors" in Mail::Message.
- $obj->
clone(%options) -
Inherited, see "Constructors" in Mail::Message
- $obj->
dup() -
Duplicate the message. The result will again be a Mail::Internet compatible object.
- $obj->
empty() -
Remove all data from this object. Very dangerous!
- $class->
new( [$arg], [%options] ) -
Inherited, see "Constructors" in Mail::Reporter
-Option --Defined in --DefaultBody undefFoldLength 79Header undefMailFrom 'KEEP'Modify falsebody Mail::Message undefbody_type Mail::Message Mail::Message::Body::Linesdeleted Mail::Message falsefield_type Mail::Message undefhead Mail::Message undefhead_type Mail::Message Mail::Message::Replace::MailHeaderlabels Mail::Message +{}messageId Mail::Message undefmessage_id Mail::Message undefmodified Mail::Message falsetrusted Mail::Message false- Body => \@lines
-
Array of
"\n"terminated lines. If not specified, the lines will be read from$arg.
- FoldLength => $octets
-
Number of characters (encoded
$octets) permitted on any refolded header line. Passed to Mail::Message::Replace::MailHeader::new(FoldLength).
- Header => $head
-
The Mail::Header object, which is passed here, is a fake one as well... It is translated into a new(head). If not given, the header will be parsed from the
$arg.
- MailFrom => 'IGNORE'|'ERROR'|'COERCE'|'KEEP'
-
What to do with leading "
"From "" lines in e-mail data. Passed to Mail::Message::Replace::MailHeader::new(MailFrom).
- Modify => BOOLEAN
-
Whether to re-fold all the incoming fields. Passed to Mail::Message::Replace::MailHeader::new(Modify).
- body => $object
- body_type => $class
- deleted => BOOLEAN
- field_type => $class
- head => $object
- head_type => $class
- labels => \@pairs|\%settings
- messageId => $id
- message_id => $id
- modified => BOOLEAN
- trusted => BOOLEAN
» example: replace traditional Mail::Internet by this wrapper
# wasuse Mail::Internet;my $mi = Mail::Internet->new(@options);# becomesuse Mail::Message::Replace::MailInternet;my $mi = Mail::Internet->new(@options);
Attributes
Extends "Attributes" in Mail::Message.
$obj->
|
Your email address. |
|---|---|
$obj->
|
Inherited, see "Attributes" in Mail::Message |
$obj->
|
Inherited, see "Attributes" in Mail::Message |
$obj->
|
Inherited, see "Attributes" in Mail::Message |
$obj->
|
Inherited, see "Attributes" in Mail::Message |
Constructing a message
Extends "Constructing a message" in Mail::Message.
- $obj->
add_signature( [$filename] ) -
Replaced by
sign(), but still usable.$filenameis the file which contains the signature, which defaults to"$ENV{HOME}/.signature".
- $obj->
bounce( [<$rg_object|%options>] ) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Bounce
- $class->
build( [$message|$part|$body], @fields, %options ) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Build
- $class->
buildFromBody($body, [$head], $headers) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Build
- $obj->
extract(\@lines|$fh) -
Read header and body from an ARRAY or
$fh
- $obj->
forward(%options) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Forward
- $obj->
forwardAttach(%options) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Forward
- $obj->
forwardEncapsulate(%options) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Forward
- $obj->
forwardInline(%options) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Forward
- $obj->
forwardNo(%options) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Forward
- $obj->
forwardPostlude() -
Inherited, see "Constructing a message" in Mail::Message::Construct::Forward
- $obj->
forwardPrelude() -
Inherited, see "Constructing a message" in Mail::Message::Construct::Forward
- $obj->
forwardSubject(STRING) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Forward
- $any->
read(\@lines|$fh, %options) -
Read header and body from the specified ARRAY or
$fh. When used as object method,Mail::Message::read()is called, to be MailBox compliant. As class method, the Mail::Internet compatible read is called.%optionsare only available in the first case. Improves base, see "Constructing a message" in Mail::Message::Construct::Read-Option --Defined in --Defaultbody_type Mail::Message::Construct::Read undefparser_class Mail::Message::Construct::Read undefseekable Mail::Message::Construct::Read falsestrip_status_fields Mail::Message::Construct::Read truetrusted Mail::Message::Construct::Read true- body_type => $type
- parser_class => $type
- seekable => BOOLEAN
- strip_status_fields => BOOLEAN
- trusted => BOOLEAN
- $obj->
read_body(\@lines|$fh) -
Read only the message's body from the ARRAY or
$fh.
- $obj->
read_header(\@lines|$fh) -
Read only the message's header from the ARRAY or
$fh
- $obj->
rebuild(%options) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Rebuild
- $obj->
reply(%options) -
BE WARNED: the main job for creating a reply is done by
Mail::Message::reply(), which may produce a result which is compatible, but may be different from Mail::Internet's version. Improves base, see "Constructing a message" in Mail::Message::Construct::Reply-Option --Defined in --DefaultBcc Mail::Message::Construct::Reply undefCc Mail::Message::Construct::Reply <'cc' in current>Exclude []From Mail::Message::Construct::Reply <'to' in current>Inline >Keep []Message-ID Mail::Message::Construct::Reply <uniquely generated>ReplyAll <C<false>>Subject Mail::Message::Construct::Reply replySubject()To Mail::Message::Construct::Reply <sender in current>body Mail::Message::Construct::Reply undefgroup_reply Mail::Message::Construct::Reply trueheader_template $ENV{HOME}/.mailhdrinclude Mail::Message::Construct::Reply 'INLINE'max_signature Mail::Message::Construct::Reply 10message_type Mail::Message::Construct::Reply Mail::Messagepostlude Mail::Message::Construct::Reply undefprelude Mail::Message::Construct::Reply undefquote Mail::Message::Construct::Reply '> 'signature Mail::Message::Construct::Reply undefstrip_signature Mail::Message::Construct::Reply qr/^--\s/- Bcc => $body|$address|\@addresses
- Cc => $body|$address|\@addresses
- Exclude => \@names
-
Remove the fields with the specified names from the produced reply message.
- From => $body|$address|\@addresses
- Inline => STRING
-
Quotation STRING, which is translated into reply(quote). The normal default of
"quote"is "> ", in stead of ">".
- Keep => \@names
-
Copy all header fields with the specified NAMES from the source to the reply message.
- Message-ID => $field|$line
- ReplyAll => BOOLEAN
-
Reply to the group? Translated into reply(group_reply), which has as default the exact oposite of this option, being
"true".
- Subject => $field|$line|CODE
- To => $body|$address|\@addresses
- body => $body
- group_reply => BOOLEAN
- header_template => $filename|undef
-
Read the return header from the template file. When this is explicitly set to
"undef", or the file does not exist, then a header will be created.
- include => 'NO'|'INLINE'|'ATTACH'
- max_signature => INTEGER
- message_type => CLASS
- postlude => $body|\@lines
- prelude => $body|\@lines
- quote => CODE|STRING
- signature => $body|$message
- strip_signature => REGEXP|STRING|CODE
- $obj->
replyPrelude( [STRING|$field|$address|\@addrs|\@fields] ) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Reply
- $any->
replySubject(STRING) -
Inherited, see "Constructing a message" in Mail::Message::Construct::Reply
- $obj->
sign(%options) -
Add a signature (a few extra lines) to the message.
-Option --DefaultFile undefSignature ''- File => $filename
-
Specifies a filename where the signature is in.
- Signature => STRING|\@lines
-
The signature in memory.
The message
Extends "The message" in Mail::Message.
- $obj->
container() -
Inherited, see "The message" in Mail::Message
- $obj->
endsOnNewline() -
Inherited, see "The message" in Mail::Message
- $obj->
isDummy() -
Inherited, see "The message" in Mail::Message
- $obj->
isPart() -
Inherited, see "The message" in Mail::Message
- $obj->
partNumber() -
Inherited, see "The message" in Mail::Message
- $obj->
print( [$fh] ) -
Prints the whole message to the specified
$fh, which default to STDOUT. This callsMail::Message::print(). Improves base, see "The message" in Mail::Message
- $obj->
send($type, %options) -
Send via Mail Transfer Agents (MUA). These will be handled by various Mail::Transport::Send extensions. The
"test"$typeis not supported. Improves base, see "The message" in Mail::Message
- $obj->
size() -
Inherited, see "The message" in Mail::Message
- $obj->
toplevel() -
Inherited, see "The message" in Mail::Message
- $obj->
write( [$fh] ) -
Inherited, see "The message" in Mail::Message
The header
Extends "The header" in Mail::Message.
- $obj->
add(\@lines) -
Add header lines, which simply calls
Mail::Message::Head::add()on the header for each specified LINE. The last added LINE is returned.
- $obj->
bcc() -
Inherited, see "The header" in Mail::Message
- $obj->
cc() -
Inherited, see "The header" in Mail::Message
- $obj->
clean_header() -
Not to be used, replaced by
header().
- $obj->
combine( $tag, [$with] ) -
Not implemented, because I see no use for it.
- $obj->
date() -
Inherited, see "The header" in Mail::Message
- $obj->
delete( $name, [$index]] ) -
Delete the fields with the specified
$name. The deleted fields are returned.BE WARNED: if no
$nameis specified, the"delete"is interpreted as the deletion of the message in a folder, soMail::Box::Message::delete()will be called. This may have no negative effect at all...Calls
Mail::Message::Replace::MailHeader::delete()Improves base, see "Flags" in Mail::Message
- $obj->
destinations() -
Inherited, see "The header" in Mail::Message
- $obj->
fold( [$length] ) -
Fold all the fields to a certain maximum
$length. Implemented byMail::Message::Replace::MailHeader::fold()
- $obj->
fold_length( [[$tag], $length] ) -
Set the maximum line
$length.$tagis ignored. Implemented byMail::Message::Replace::MailHeader::fold_length()
- $obj->
from() -
Inherited, see "The header" in Mail::Message
- $obj->
get( $name, [$index] ) -
Get all the header fields with the specified
$name. In scalar context, only the first fitting$nameis returned. Even when only one$nameis specified, multiple lines may be returned: some fields appear more than once in a header. CallsMail::Message::Replace::MailHeader::get()Improves base, see "The header" in Mail::Message
- $obj->
guessTimestamp() -
Inherited, see "The header" in Mail::Message
- $obj->
head( [$head] ) -
Returns the head of the message, or creates an empty one if none is defined. The
$headargument, which sets the header, is not available for Mail::Internet, but is there to be compatible with the"head"method of Mail::Message. Improves base, see "The header" in Mail::Message
- $obj->
header( [\@lines] ) -
Optionally reads a header from the ARRAY of lines, and then returns those fields as array-ref nicely folded. Implemented by
Mail::Message::Replace::MailHeader::header()
- $obj->
nrLines() -
Inherited, see "The header" in Mail::Message
- $obj->
print_header($fh) -
Calls
Mail::Message::Head::Complete::print().
- $obj->
replace( $tag, $line, [$index] ) -
Adds LINES to the header, but removes fields with the same name if they already exist. Calls
Mail::Message::Replace::MailHeader::replace()
- $obj->
sender() -
Inherited, see "The header" in Mail::Message
- $obj->
study($fieldname) -
Inherited, see "The header" in Mail::Message
- $obj->
subject() -
Inherited, see "The header" in Mail::Message
- $obj->
tidy_headers() -
No effect anymore (always performed).
- $obj->
timestamp() -
Inherited, see "The header" in Mail::Message
- $obj->
to() -
Inherited, see "The header" in Mail::Message
The body
Extends "The body" in Mail::Message.
- $obj->
body($lines|@lines) -
Returns an ARRAY of lines, representing the body. With arguments, a new body will be created. In Mail::Internet, the body is not an object but a simple array.
BE WARNED: this overrules the
Mail::Message::body()method, which may cause some confusion. UsebodyObject()to get access to that body's data. Improves base, see "The body" in Mail::Message
- $obj->
bodyObject( [$body] ) -
Calls
Mail::Message::body(), because that"body"method is overruled by the one which has a Mail::Internet compatible interface.
- $obj->
contentType() -
Inherited, see "The body" in Mail::Message
- $obj->
decoded(%options) -
Inherited, see "The body" in Mail::Message
- $obj->
encode(%options) -
Inherited, see "The body" in Mail::Message
- $obj->
isMultipart() -
Inherited, see "The body" in Mail::Message
- $obj->
isNested() -
Inherited, see "The body" in Mail::Message
- $obj->
parts( [<'ALL'|'ACTIVE'|'DELETED'|'RECURSE'|$filter>] ) -
Inherited, see "The body" in Mail::Message
- $obj->
print_body( [$fh] ) -
Prints the body to the specified
$fh, which defaults to STDOUT. This callsMail::Message::Body::print().
- $obj->
remove_sig( [$nrlines] ) -
Remove the signature of a message with a maximum of
$nrlineslines, which defaults to 10. The work is done on the decoded body content, byMail::Message::Body::stripSignature().
- $obj->
smtpsend(%options) -
This method is calling
Mail::Message::send()via"smtp", which is implemented in Mail::Transport::SMTP. The implementation is slightly different, so this method is not 100% compliant.-Option --DefaultDebug falseHello <helo_domain from Net::Config>Host $ENV{SMTPHOSTS} or from Net::ConfigMailFrom $ENV{MAILADDRESS} or $ENV{USER}Port 25- Debug => BOOLEAN
- Hello => STRING
- Host => $hostname
-
Only the first detected
$hostnameis taken, so differs from the original implementation.
- MailFrom => STRING
-
Your e-mail address. This simulated Mail::Internet 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.
- Port => INTEGER
- $obj->
tidy_body() -
Removes blank lines from begin and end of the body.
Flags
Extends "Flags" in Mail::Message.
$obj->
|
Inherited, see "Flags" in Mail::Message |
|---|---|
$obj->
|
Inherited, see "Flags" in Mail::Message |
$obj->
|
Inherited, see "Flags" in Mail::Message |
$obj->
|
Inherited, see "Flags" in Mail::Message |
$obj->
|
Inherited, see "Flags" in Mail::Message |
$obj->
|
Inherited, see "Flags" in Mail::Message |
$obj->
|
Inherited, see "Flags" in Mail::Message |
$obj->
|
Inherited, see "Flags" in Mail::Message |
The whole message as text
Extends "The whole message as text" in Mail::Message.
- $obj->
as_mbox_string() -
Returns the whole message as one string, which can be included in an MBOX folder (while not using Mail::Box::Mbox). Lines in the body which start with
"From "are escaped with an >.
- $obj->
file() -
Inherited, see "The whole message as text" in Mail::Message::Construct::Text
- $obj->
lines() -
Inherited, see "The whole message as text" in Mail::Message::Construct::Text
- $obj->
printStructure( [$fh|undef],[$indent] ) -
Inherited, see "The whole message as text" in Mail::Message::Construct::Text
- $obj->
string() -
Inherited, see "The whole message as text" in Mail::Message::Construct::Text
The nasty bits
- $any->
isa($class) -
Of course, the
isa()class inheritance check should not see our nasty trick.
Internals
Extends "Internals" in Mail::Message.
- $obj->
clonedFrom() -
Inherited, see "Internals" in Mail::Message
- $class->
coerce($message) -
Coerce (adapt type) of the specified
$message(anythingMail::Message::coerce()accepts) into an Mail::Internet simulating object. Improves base, see "Internals" in Mail::Message
- $obj->
isDelayed() -
Inherited, see "Internals" in Mail::Message
- $obj->
isTrusted() -
Inherited, see "Internals" in Mail::Message
- $obj->
readBody( $parser, $head, [$bodytype] ) -
Inherited, see "Internals" in Mail::Message
- $obj->
readFromParser( $parser, [$bodytype] ) -
Inherited, see "Internals" in Mail::Message
- $obj->
readHead( $parser, [$class] ) -
Inherited, see "Internals" in Mail::Message
- $obj->
recursiveRebuildPart($part, %options) -
Inherited, see "Internals" in Mail::Message::Construct::Rebuild
- $obj->
storeBody($body) -
Inherited, see "Internals" in Mail::Message
- $obj->
takeMessageId( [STRING] ) -
Inherited, see "Internals" in Mail::Message
Error handling
Extends "Error handling" in Mail::Message.
$obj->AUTOLOAD()
|
Inherited, see "METHODS" in Mail::Message::Construct |
|---|---|
$obj->
|
Inherited, see "Error handling" in Mail::Reporter |
$any->
|
Inherited, see "Error handling" in Mail::Message |
$obj->
|
Inherited, see "Error handling" in Mail::Message |
Cleanup
Extends "Cleanup" in Mail::Message.
$obj->DESTROY()
|
Inherited, see "Cleanup" in Mail::Reporter |
|---|---|
$obj->
|
Inherited, see "Cleanup" in Mail::Message |
Details
Extends "DETAILS" in Mail::Message.
Diagnostics
- Error: Cannot include forward source as $kind.
-
Unknown alternative for the forward(include). Valid choices are
"NO","INLINE","ATTACH", and"ENCAPSULATE". Cast byforward()
- Error: Mail::Internet does not support $what data.
-
The data can only be a file handle or an ARRAY. Other data types are not supported (see
read()if you want to have more). Cast bynew()
- 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()
- Error: method bounce requires To, Cc, or Bcc.
-
The message
bounce()method forwards a received message off to someone else without modification; you must specified it's new destination. If you have the urge not to specify any destination, you probably are looking forreply(). When you wish to modify the content, useforward(). Cast bybounce()
- Error: method forwardAttach requires a preamble.
-
Cast by
forwardAttach()
- Error: method forwardEncapsulate requires a preamble.
-
Cast by
forwardEncapsulate()
- Error: method forwardNo requires a To.
-
Cast by
forwardNo()
- Error: method forwardNo requires a body.
-
Cast by
forwardNo()
- Error: no rebuild rule $name defined.
-
Cast by
rebuild()
- Error: only
build()Mail::Message's; they are not in a folder yet. -
You may wish to construct a message to be stored in a some kind of folder, but you need to do that in two steps. First, create a normal Mail::Message, and then add it to the folder. During this
Mail::Box::addMessage()process, the message will getcoerce()-d into the right message type, adding storage information and the like. Cast bybuild()
- Error: select parts via '$what'?
-
Cast by
parts()
- Warning: skipped unknown key '$key' in build.
-
Cast by
build()
Releases
12 releases since Debian 3.1 (Sarge); the text changed 11 times.