{
    "content": [
        {
            "type": "text",
            "text": "# Mail::Message (perldoc)\n\n## NAME\n\nMail::Message - general message object\n\n## SYNOPSIS\n\nuse Mail::Box::Manager;\nmy $mgr    = Mail::Box::Manager->new;\nmy $folder = $mgr->open(folder => 'InBox');\nmy $msg    = $folder->message(2);    # $msg is a Mail::Message now\nmy $subject = $msg->subject;         # The message's subject\nmy @cc      = $msg->cc;              # List of Mail::Address'es\nmy Mail::Message::Head $head = $msg->head;\nmy Mail::Message::Body $body = $msg->decoded;\n$msg->decoded->print($outfile);\n# Send a simple email\nMail::Message->build\n( To             => 'you@example.com'\n, From           => 'me@example.com'\n, Subject        => \"My subject\"\n, data           => \"Some plain text content\"\n)->send(via => 'postfix');\nmy $replymsg = Mail::Message->reply(...);\nmy $frwdmsg  = Mail::Message->forward(...);\n\n## DESCRIPTION\n\nA \"Mail::Message\" object is a container for MIME-encoded message information, as defined by\nRFC2822. Everything what is not specificaly related to storing the messages in mailboxes\n(folders) is implemented in this class. Methods which are related to folders is implemented in\nthe Mail::Box::Message extension.\n\n## Sections\n\n- **NAME**\n- **INHERITANCE**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS** (10 subsections)\n- **DETAILS** (4 subsections)\n- **DIAGNOSTICS**\n- **SEE ALSO**\n- **LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Mail::Message",
        "section": "",
        "mode": "perldoc",
        "summary": "Mail::Message - general message object",
        "synopsis": "use Mail::Box::Manager;\nmy $mgr    = Mail::Box::Manager->new;\nmy $folder = $mgr->open(folder => 'InBox');\nmy $msg    = $folder->message(2);    # $msg is a Mail::Message now\nmy $subject = $msg->subject;         # The message's subject\nmy @cc      = $msg->cc;              # List of Mail::Address'es\nmy Mail::Message::Head $head = $msg->head;\nmy Mail::Message::Body $body = $msg->decoded;\n$msg->decoded->print($outfile);\n# Send a simple email\nMail::Message->build\n( To             => 'you@example.com'\n, From           => 'me@example.com'\n, Subject        => \"My subject\"\n, data           => \"Some plain text content\"\n)->send(via => 'postfix');\nmy $replymsg = Mail::Message->reply(...);\nmy $frwdmsg  = Mail::Message->forward(...);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "INHERITANCE",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 2,
                "subsections": [
                    {
                        "name": "Constructors",
                        "lines": 96
                    },
                    {
                        "name": "Constructing a message",
                        "lines": 49
                    },
                    {
                        "name": "The message",
                        "lines": 108
                    },
                    {
                        "name": "The header",
                        "lines": 134
                    },
                    {
                        "name": "The body",
                        "lines": 77
                    },
                    {
                        "name": "Flags",
                        "lines": 90
                    },
                    {
                        "name": "The whole message as text",
                        "lines": 12
                    },
                    {
                        "name": "Internals",
                        "lines": 82
                    },
                    {
                        "name": "Error handling",
                        "lines": 52
                    },
                    {
                        "name": "Cleanup",
                        "lines": 20
                    }
                ]
            },
            {
                "name": "DETAILS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Structure of a Message",
                        "lines": 20
                    },
                    {
                        "name": "Message object implementation",
                        "lines": 28
                    },
                    {
                        "name": "Message class implementation",
                        "lines": 38
                    },
                    {
                        "name": "Labels",
                        "lines": 81
                    }
                ]
            },
            {
                "name": "DIAGNOSTICS",
                "lines": 39,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Mail::Message - general message object\n",
                "subsections": []
            },
            "INHERITANCE": {
                "content": "Mail::Message has extra code in\nMail::Message::Construct\nMail::Message::Construct::Bounce\nMail::Message::Construct::Build\nMail::Message::Construct::Forward\nMail::Message::Construct::Read\nMail::Message::Construct::Rebuild\nMail::Message::Construct::Reply\nMail::Message::Construct::Text\n\nMail::Message\nis a Mail::Reporter\n\nMail::Message is extended by\nMail::Box::Message\nMail::Message::Dummy\nMail::Message::Part\nMail::Message::Replace::MailInternet\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Mail::Box::Manager;\nmy $mgr    = Mail::Box::Manager->new;\nmy $folder = $mgr->open(folder => 'InBox');\nmy $msg    = $folder->message(2);    # $msg is a Mail::Message now\n\nmy $subject = $msg->subject;         # The message's subject\nmy @cc      = $msg->cc;              # List of Mail::Address'es\n\nmy Mail::Message::Head $head = $msg->head;\nmy Mail::Message::Body $body = $msg->decoded;\n$msg->decoded->print($outfile);\n\n# Send a simple email\nMail::Message->build\n( To             => 'you@example.com'\n, From           => 'me@example.com'\n, Subject        => \"My subject\"\n, data           => \"Some plain text content\"\n)->send(via => 'postfix');\n\nmy $replymsg = Mail::Message->reply(...);\nmy $frwdmsg  = Mail::Message->forward(...);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "A \"Mail::Message\" object is a container for MIME-encoded message information, as defined by\nRFC2822. Everything what is not specificaly related to storing the messages in mailboxes\n(folders) is implemented in this class. Methods which are related to folders is implemented in\nthe Mail::Box::Message extension.\n\nThe main methods are get(), to get information from a message header field, and decoded() to get\nthe intended content of a message. But there are many more which can assist your program.\n\nComplex message handling, like construction of replies and forwards, are implemented in separate\npackages which are autoloaded into this class. This means you can simply use these methods as if\nthey are part of this class. Those package add functionality to all kinds of message objects.\n\nExtends \"DESCRIPTION\" in Mail::Reporter.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "Extends \"METHODS\" in Mail::Reporter.\n",
                "subsections": [
                    {
                        "name": "Constructors",
                        "content": "Extends \"Constructors\" in Mail::Reporter.\n\n$obj->clone(%options)\nCreate a copy of this message. Returned is a \"Mail::Message\" object. The head and body, the\nlog and trace levels are taken. Labels are copied with the message, but the delete and\nmodified flags are not.\n\nBE WARNED: the clone of any kind of message (or a message part) will always be a\n\"Mail::Message\" object. For example, a Mail::Box::Message's clone is detached from the\nfolder of its original. When you use Mail::Box::addMessage() with the cloned message at\nhand, then the clone will automatically be coerced into the right message type to be added.\n\nSee also Mail::Box::Message::copyTo() and Mail::Box::Message::moveTo().\n\n-Option      --Default\nshallow       <false>\nshallowbody  <false>\nshallowhead  <false>\n\nshallow => BOOLEAN\nWhen a shallow clone is made, the header and body of the message will not be cloned, but\nshared. This is quite dangerous: for instance in some folder types, the header fields are\nused to store folder flags. When one of both shallow clones change the flags, that will\nupdate the header and thereby be visible in both.\n\nThere are situations where a shallow clone can be used safely. For instance, when\nMail::Box::Message::moveTo() is used and you are sure that the original message cannot get\nundeleted after the move.\n\nshallowbody => BOOLEAN\nA rather safe bet, because you are not allowed to modify the body of a message: you may\nonly set a new body with body().\n\nshallowhead => BOOLEAN\nOnly the head uses is reused, not the body. This is probably a bad choice, because the\nheader fields can be updated, for instance when labels change.\n\nexample:\n\n$copy = $msg->clone;\n\nMail::Message->new(%options)\n-Option    --Defined in     --Default\nbody                         undef\nbodytype                    Mail::Message::Body::Lines\ndeleted                      <false>\nfieldtype                   undef\nhead                         undef\nheadtype                    Mail::Message::Head::Complete\nlabels                       {}\nlog         Mail::Reporter   'WARNINGS'\nmessageId                    undef\nmodified                     <false>\ntrace       Mail::Reporter   'WARNINGS'\ntrusted                      <false>\n\nbody => OBJECT\nInstantiate the message with a body which has been created somewhere before the message is\nconstructed. The OBJECT must be a sub-class of Mail::Message::Body. See also body() and\nstoreBody().\n\nbodytype => CLASS\nDefault type of body to be created for readBody().\n\ndeleted => BOOLEAN\nIs the file deleted from the start?\n\nfieldtype => CLASS\nhead => OBJECT\nInstantiate the message with a head which has been created somewhere before the message is\nconstructed. The OBJECT must be a (sub-)class of Mail::Message::Head. See also head().\n\nheadtype => CLASS\nDefault type of head to be created for readHead().\n\nlabels => ARRAY|HASH\nInitial values of the labels. In case of Mail::Box::Message's, this shall reflect the\nstate the message is in. For newly constructed Mail::Message's, this may be anything you\nwant, because coerce() will take care of the folder specifics once the message is added to\none.\n\nlog => LEVEL\nmessageId => STRING\nThe id on which this message can be recognized. If none specified and not defined in the\nheader --but one is needed-- there will be one assigned to the message to be able to pass\nunique message-ids between objects.\n\nmodified => BOOLEAN\nFlags this message as being modified from the beginning on. Usually, modification is\nauto-detected, but there may be reasons to be extra explicit.\n\ntrace => LEVEL\ntrusted => BOOLEAN\nIs this message from a trusted source? If not, the content must be checked before use.\nThis checking will be performed when the body data is decoded or used for transmission.\n"
                    },
                    {
                        "name": "Constructing a message",
                        "content": "$obj->bounce( [<$rgobject|%options>] )\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Bounce\n\nMail::Message->build( [$message|$part|$body], $content )\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Build\n\nMail::Message->buildFromBody($body, [$head], $headers)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Build\n\n$obj->forward(%options)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Forward\n\n$obj->forwardAttach(%options)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Forward\n\n$obj->forwardEncapsulate(%options)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Forward\n\n$obj->forwardInline(%options)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Forward\n\n$obj->forwardNo(%options)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Forward\n\n$obj->forwardPostlude()\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Forward\n\n$obj->forwardPrelude()\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Forward\n\n$obj->forwardSubject(STRING)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Forward\n\nMail::Message->read($fh|STRING|SCALAR|ARRAY, %options)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Read\n\n$obj->rebuild(%options)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Rebuild\n\n$obj->reply(%options)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Reply\n\n$obj->replyPrelude( [STRING|$field|$address|ARRAY-$of-$things] )\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Reply\n\n$obj->replySubject(STRING)\nMail::Message->replySubject(STRING)\nInherited, see \"Constructing a message\" in Mail::Message::Construct::Reply\n"
                    },
                    {
                        "name": "The message",
                        "content": "$obj->container()\nIf the message is a part of another message, \"container\" returns the reference to the\ncontaining body.\n\nexample:\n\nmy Mail::Message $msg = ...\nreturn unless $msg->body->isMultipart;\nmy $part   = $msg->body->part(2);\n\nreturn unless $part->body->isMultipart;\nmy $nested = $part->body->part(3);\n\n$nested->container;  # returns $msg->body\n$nested->toplevel;   # returns $msg\n$msg->container;     # returns undef\n$msg->toplevel;      # returns $msg\n$msg->isPart;        # returns false\n$part->isPart;       # returns true\n\n$obj->isDummy()\nDummy messages are used to fill holes in linked-list and such, where only a message-id is\nknown, but not the place of the header of body data.\n\nThis method is also available for Mail::Message::Dummy objects, where this will return\n\"true\". On any extension of \"Mail::Message\", this will return \"false\".\n\n$obj->isPart()\nReturns true if the message is a part of another message. This is the case for\nMail::Message::Part extensions of \"Mail::Message\".\n\n$obj->messageId()\nRetrieve the message's id. Every message has a unique message-id. This id is used mainly for\nrecognizing discussion threads.\n\n$obj->partNumber()\nReturns a string representing the location of this part. In case the top message is a single\nmessage, 'undef' is returned. When it is a multipart, '1' up to the number of multiparts is\nreturned. A multi-level nested part may for instance return '2.5.1'.\n\nUsually, this string is very short. Numbering follows the IMAP4 design, see RFC2060 section\n6.4.5.\n\n$obj->print( [$fh] )\nPrint the message to the FILE-HANDLE, which defaults to the selected filehandle, without the\nencapsulation sometimes required by a folder type, like write() does.\n\nexample:\n\n$message->print(\\*STDERR);  # to the error output\n$message->print;            # to the selected file\n\nmy $out = IO::File->new('out', 'w');\n$message->print($out);      # no encapsulation: no folder\n$message->write($out);      # with encapsulation: is folder.\n\n$obj->send( [$mailer], %options )\nTransmit the message to anything outside this Perl program. Returns false when sending\nfailed even after retries.\n\nThe optional $mailer is a Mail::Transport::Send object. When the $mailer is not specified,\none will be created and kept as default for the next messages as well.\n\nThe %options are mailer specific, and a mixture of what is usable for the creation of the\nmailer object and the sending itself. Therefore, see for possible options\nMail::Transport::Send::new() and Mail::Transport::Send::send(). That object also provides a\n\"trySend()\" method which gives more low-level control.\n\nexample:\n\n$message->send;\n\nis short (but little less flexibile) for\n\nmy $mailer = Mail::Transport::SMTP->new(@smtpopts);\n$mailer->send($message, @sendopts);\n\nSee examples/send.pl in the distribution of Mail::Box.\n\nexample:\n\n$message->send(via => 'sendmail')\n\n$obj->size()\nReturns an estimated size of the whole message in bytes. In many occasions, the functions\nwhich process the message further, for instance send() or print() will need to add/change\nheader lines or add CR characters, so the size is only an estimate with a few percent margin\nof the real result.\n\nThe computation assumes that each line ending is represented by one character (like UNIX,\nMacOS, and sometimes Cygwin), and not two characters (like Windows and sometimes Cygwin). If\nyou write the message to file on a system which uses CR and LF to end a single line (all\nWindows versions), the result in that file will be at least nrLines() larger than this\nmethod returns.\n\n$obj->toplevel()\nReturns a reference to the main message, which will be the current message if the message is\nnot part of another message.\n\n$obj->write( [$fh] )\nWrite the message to the FILE-HANDLE, which defaults to the selected $fh, with all\nsurrounding information which is needed to put it correctly in a folder file.\n\nIn most cases, the result of \"write\" will be the same as with print(). The main exception is\nfor Mbox folder messages, which will get printed with their leading 'From ' line and a\ntrailing blank. Each line of their body which starts with 'From ' will have an '>' added in\nfront.\n"
                    },
                    {
                        "name": "The header",
                        "content": "$obj->bcc()\nReturns the addresses which are specified on the \"Bcc\" header line (or lines) A list of\nMail::Address objects is returned. \"Bcc\" stands for *Blind Carbon Copy*: destinations of the\nmessage which are not listed in the messages actually sent. So, this field will be empty for\nreceived messages, but may be present in messages you construct yourself.\n\n$obj->cc()\nReturns the addresses which are specified on the \"Cc\" header line (or lines) A list of\nMail::Address objects is returned. \"Cc\" stands for *Carbon Copy*; the people addressed on\nthis line receive the message informational, and are usually not expected to reply on its\ncontent.\n\n$obj->date()\nMethod has been removed for reasons of consistency. Use timestamp() or\n\"$msg->head->get('Date')\".\n\n$obj->destinations()\nReturns a list of Mail::Address objects which contains the combined info of active \"To\",\n\"Cc\", and \"Bcc\" addresses. Double addresses are removed if detectable.\n\n$obj->from()\nReturns the addresses from the senders. It is possible to have more than one address\nspecified in the \"From\" field of the message, according to the specification. Therefore a\nlist of Mail::Address objects is returned, which usually has length 1.\n\nIf you need only one address from a sender, for instance to create a \"original message by\"\nline in constructed forwarded message body, then use sender().\n\nexample: using from() to get all sender addresses\n\nmy @from = $message->from;\n\n$obj->get($fieldname)\nReturns the value which is stored in the header field with the specified name. The\n$fieldname is case insensitive. The *unfolded body* of the field is returned, stripped from\nany attributes. See Mail::Message::Field::body().\n\nIf the field has multiple appearances in the header, only the last instance is returned. If\nyou need more complex handing of fields, then call Mail::Message::Head::get() yourself. See\nstudy() when you want to be smart, doing the better (but slower) job.\n\nexample: the get() short-cut for header fields\n\nprint $msg->get('Content-Type'), \"\\n\";\n\nIs equivalent to:\n\nprint $msg->head->get('Content-Type')->body, \"\\n\";\n\n$obj->guessTimestamp()\nReturn an estimate on the time this message was sent. The data is derived from the header,\nwhere it can be derived from the \"date\" and \"received\" lines. For MBox-like folders you may\nget the date from the from-line as well.\n\nThis method may return \"undef\" if the header is not parsed or only partially known. If you\nrequire a time, then use the timestamp() method, described below.\n\nexample: using guessTimestamp() to get a transmission date\n\nprint \"Receipt \", ($message->timestamp || 'unknown'), \"\\n\";\n\n$obj->head( [$head] )\nReturn (optionally after setting) the $head of this message. The head must be an (sub-)class\nof Mail::Message::Head. When the head is added, status information is taken from it and\ntransformed into labels. More labels can be added by the LABELS hash. They are added later.\n\nexample:\n\nmy $header = Mail::Message::Head->new;\n$msg->head($header);    # set\nmy $head = $msg->head;  # get\n\n$obj->nrLines()\nReturns the number of lines used for the whole message.\n\n$obj->sender()\nReturns exactly one address, which is the originator of this message. The returned\nMail::Address object is taken from the \"Sender\" header field, unless that field does not\nexists, in which case the first address from the \"From\" field is taken. If none of both\nprovide an address, \"undef\" is returned.\n\nexample: using sender() to get exactly one sender address\n\nmy $sender = $message->sender;\nprint \"Reply to: \", $sender->format, \"\\n\" if defined $sender;\n\n$obj->study($fieldname)\nStudy the content of a field, like get() does, with as main difference that a\nMail::Message::Field::Full object is returned. These objects stringify to an utf8 decoded\nrepresentation of the data contained in the field, where get() does not decode. When the\nfield does not exist, then \"undef\" is returned. See Mail::Message::Field::study().\n\nexample: the study() short-cut for header fields\n\nprint $msg->study('to'), \"\\n\";\n\nIs equivalent to:\n\nprint $msg->head->study('to'), \"\\n\";       # and\nprint $msg->head->get('to')->study, \"\\n\";\n\nor better: if(my $to = $msg->study('to')) { print \"$to\\n\" } if(my $to = $msg->get('to')) {\nprint $to->study, \"\\n\" }\n\n$obj->subject()\nReturns the message's subject, or the empty string. The subject may have encoded characters\nin it; use study() to get rit of that.\n\nexample: using subject() to get the message's subject\n\nprint $msg->subject;\nprint $msg->study('subject');\n\n$obj->timestamp()\nGet a good timestamp for the message, doesn't matter how much work it is. The value returned\nis compatible with the platform dependent result of function time().\n\nIn these days, the timestamp as supplied by the message (in the \"Date\" field) is not\ntrustable at all: many spammers produce illegal or unreal dates to influence their location\nin the displayed folder.\n\nTo start, the received headers are tried for a date (see\nMail::Message::Head::Complete::recvstamp()) and only then the \"Date\" field. In very rare\ncases, only with some locally produced messages, no stamp can be found.\n\n$obj->to()\nReturns the addresses which are specified on the \"To\" header line (or lines). A list of\nMail::Address objects is returned. The people addressed here are the targets of the content,\nand should read it contents carefully.\n\nexample: using to() to get all primar destination addresses\n\nmy @to = $message->to;\n"
                    },
                    {
                        "name": "The body",
                        "content": "$obj->body( [$body] )\nReturn the body of this message. BE WARNED that this returns you an object which may be\nencoded: use decoded() to get a body with usable data.\n\nWith options, a new $body is set for this message. This is not for normal use unless you\nunderstand the consequences: you change the message content without changing the message-ID.\nThe right way to go is via\n\n$message = Mail::Message->buildFromBody($body);  # or\n$message = Mail::Message->build($body);          # or\n$message = $origmsg->forward(body => $body);\n\nThe $body must be an (sub-)class of Mail::Message::Body. In this case, information from the\nspecified body will be copied into the header. The body object will be encoded if needed,\nbecause messages written to file or transmitted shall not contain binary data. The converted\nbody is returned.\n\nWhen $body is \"undef\", the current message body will be dissected from the message. All\nrelation will be cut. The body is returned, and can be connected to a different message.\n\nexample:\n\nmy $body      = $msg->body;\nmy @encoded   = $msg->body->lines;\n\nmy $new       = Mail::Message::Body->new(mimetype => 'text/html');\nmy $converted = $msg->body($new);\n\n$obj->contentType()\nReturns the content type header line, or \"text/plain\" if it is not defined. The parameters\nwill be stripped off.\n\n$obj->decoded(%options)\nDecodes the body of this message, and returns it as a body object. Short for\n\"$msg->body->decoded\" All %options are passed-on.\n\n$obj->encode(%options)\nEncode the message to a certain format. Read the details in the dedicated manual page\nMail::Message::Body::Encode. The %options which can be specified here are those of the\nMail::Message::Body::encode() method.\n\n$obj->isMultipart()\nCheck whether this message is a multipart message (has attachments). To find this out, we\nneed at least the header of the message; there is no need to read the body of the message to\ndetect this.\n\n$obj->isNested()\nReturns \"true\" for \"message/rfc822\" messages and message parts.\n\n$obj->parts( [<'ALL'|'ACTIVE'|'DELETED'|'RECURSE'|$filter>] )\nReturns the *parts* of this message. Maybe a bit inconvenient: it returns the message itself\nwhen it is not a multipart.\n\nUsually, the term *part* is used with *multipart* messages: messages which are encapsulated\nin the body of a message. To abstract this concept: this method will return you all\nheader-body combinations which are stored within this message except the multipart and\nmessage/rfc822 wrappers. Objects returned are \"Mail::Message\"'s and Mail::Message::Part's.\n\nThe option default to 'ALL', which will return the message itself for single-parts, the\nnested content of a message/rfc822 object, respectively the parts of a multipart without\nrecursion. In case of 'RECURSE', the parts of multiparts will be collected recursively. This\noption cannot be combined with the other options, which you may want: it that case you have\nto test yourself.\n\n'ACTIVE' and 'DELETED' check for the deleted flag on messages and message parts. The $filter\nis a code reference, which is called for each part of the message; each part as \"RECURSE\"\nwould return.\n\nexample:\n\nmy @parts = $msg->parts;           # $msg not multipart: returns ($msg)\nmy $parts = $msg->parts('ACTIVE'); # returns ($msg)\n\n$msg->delete;\nmy @parts = $msg->parts;           # returns ($msg)\nmy $parts = $msg->parts('ACTIVE'); # returns ()\n"
                    },
                    {
                        "name": "Flags",
                        "content": "$obj->delete()\nFlag the message to be deleted, which is a shortcut for $msg->label(deleted => time); The\nreal deletion only takes place on a synchronization of the folder. See deleted() as well.\n\nThe time stamp of the moment of deletion is stored as value, but that is not always\npreserved in the folder (depends on the implementation). When the same message is deleted\nmore than once, the first time stamp will stay.\n\nexample:\n\n$message->delete;\n$message->deleted(1);  # exactly the same\n$message->label(deleted => 1);\ndelete $message;\n\n$obj->deleted( [BOOLEAN] )\nSet the delete flag for this message. Without argument, the method returns the same as\nisDeleted(), which is preferred. When a true value is given, delete() is called.\n\nexample:\n\n$message->deleted(1);          # delete\n$message->delete;              # delete (preferred)\n\n$message->deleted(0);          # undelete\n\nif($message->deleted) {...}    # check\nif($message->isDeleted) {...}  # check (preferred)\n\n$obj->isDeleted()\nShort-cut for $msg->label('deleted')\n\nFor some folder types, you will get the time of deletion in return. This depends on the\nimplementation.\n\nexample:\n\nnext if $message->isDeleted;\n\nif(my $when = $message->isDeleted) {\nprint scalar localtime $when;\n}\n\n$obj->isModified()\nReturns whether this message is flagged as being modified. Modifications are changes in\nheader lines, when a new body is set to the message (dangerous), or when labels change.\n\n$obj->label($label|PAIRS)\nReturn the value of the $label, optionally after setting some values. In case of setting\nvalues, you specify key-value PAIRS.\n\nLabels are used to store knowledge about handling of the message within the folder. Flags\nabout whether a message was read, replied to, or scheduled for deletion.\n\nSome labels are taken from the header's \"Status\" and \"X-Status\" lines. Folder types like MH\ndefine a separate label file, and Maildir adds letters to the message filename. But the\nMailBox labels are always the same.\n\nexample:\n\nprint $message->label('seen');\nif($message->label('seen')) {...};\n$message->label(seen => 1);\n\n$message->label(deleted => 1);  # same as $message->delete\n\n$obj->labels()\nReturns all known labels. In SCALAR context, it returns the knowledge as reference to a\nhash. This is a reference to the original data, but you shall *not* change that data\ndirectly: call \"label\" for changes!\n\nIn LIST context, you get a list of names which are defined. Be warned that they will not all\nevaluate to true, although most of them will.\n\n$obj->labelsToStatus()\nWhen the labels were changed, that may effect the \"Status\" and/or \"X-Status\" header lines of\nmbox messages. Read about the relation between these fields and the labels in the DETAILS\nchapter.\n\nThe method will carefully only affect the result of modified() when there is a real change\nof flags, so not for each call to label().\n\n$obj->modified( [BOOLEAN] )\nReturns (optionally after setting) whether this message is flagged as being modified. See\nisModified().\n\n$obj->statusToLabels()\nUpdate the labels according the status lines in the header. See the description in the\nDETAILS chapter.\n"
                    },
                    {
                        "name": "The whole message as text",
                        "content": "$obj->file()\nInherited, see \"The whole message as text\" in Mail::Message::Construct::Text\n\n$obj->lines()\nInherited, see \"The whole message as text\" in Mail::Message::Construct::Text\n\n$obj->printStructure( [$fh|undef],[$indent] )\nInherited, see \"The whole message as text\" in Mail::Message::Construct::Text\n\n$obj->string()\nInherited, see \"The whole message as text\" in Mail::Message::Construct::Text\n"
                    },
                    {
                        "name": "Internals",
                        "content": "$obj->clonedFrom()\nReturns the $message which is the source of this message, which was created by a clone()\noperation.\n\nMail::Message->coerce($message, %options)\nCoerce a $message into a Mail::Message. In some occasions, for instance where you add a\nmessage to a folder, this coercion is automatically called to ensure that the correct\nmessage type is stored.\n\nThe coerced message is returned on success, otherwise \"undef\". The coerced message may be a\nreblessed version of the original message or a new object. In case the message has to be\nspecialized, for instance from a general Mail::Message into a Mail::Box::Mbox::Message, no\ncopy is needed. However, to coerce a Mail::Internet object into a Mail::Message, a lot of\ncopying and converting will take place.\n\nValid MESSAGEs which can be coerced into Mail::Message objects are of type\n\n*   Any type of Mail::Box::Message\n\n*   MIME::Entity objects, using Mail::Message::Convert::MimeEntity\n\n*   Mail::Internet objects, using Mail::Message::Convert::MailInternet\n\n*   Email::Simple objects, using Mail::Message::Convert::EmailSimple\n\n*   Email::Abstract objects\n\nMail::Message::Part's, which are extensions of \"Mail::Message\"'s, can also be coerced\ndirectly from a Mail::Message::Body.\n\nexample:\n\nmy $folder  = Mail::Box::Mbox->new;\nmy $message = Mail::Message->build(...);\n\nmy $coerced = Mail::Box::Mbox::Message->coerce($message);\n$folder->addMessage($coerced);\n\nSimpler replacement for the previous two lines:\n\nmy $coerced = $folder->addMessage($message);\n\n$obj->isDelayed()\nCheck whether the message is delayed (not yet read from file). Returns true or false,\ndependent on the body type.\n\n$obj->readBody( $parser, $head, [$bodytype] )\nRead a body of a message. The $parser is the access to the folder's file, and the $head is\nalready read. Information from the $head is used to create expectations about the message's\nlength, but also to determine the mime-type and encodings of the body data.\n\nThe $bodytype determines which kind of body will be made and defaults to the value specified\nby new(bodytype). $bodytype may be the name of a body class, or a reference to a routine\nwhich returns the body's class when passed the $head as only argument.\n\n$obj->readFromParser( $parser, [$bodytype] )\nRead one message from file. The $parser is opened on the file. First readHead() is called,\nand the head is stored in the message. Then readBody() is called, to produce a body. Also\nthe body is added to the message without decodings being done.\n\nThe optional $bodytype may be a body class or a reference to a code which returns a\nbody-class based on the header.\n\n$obj->readHead( $parser, [$class] )\nRead a head into an object of the specified $class. The $class defaults to new(headtype).\nThe $parser is the access to the folder's file.\n\n$obj->recursiveRebuildPart($part, %options)\nInherited, see \"Internals\" in Mail::Message::Construct::Rebuild\n\n$obj->storeBody($body)\nWhere the body() method can be used to set and get a body, with all the necessary checks,\nthis method is bluntly adding the specified body to the message. No conversions, not\nchecking.\n\n$obj->takeMessageId( [STRING] )\nTake the message-id from the STRING, or create one when the \"undef\" is specified. If not\nSTRING nor \"undef\" is given, the current header of the message is requested for the value of\nthe 'Message-ID' field.\n\nAngles (if present) are removed from the id.\n"
                    },
                    {
                        "name": "Error handling",
                        "content": "Extends \"Error handling\" in Mail::Reporter.\n\n$obj->AUTOLOAD()\nInherited, see \"METHODS\" in Mail::Message::Construct\n\n$obj->addReport($object)\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )\nMail::Message->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->errors()\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->log( [$level, [$strings]] )\nMail::Message->log( [$level, [$strings]] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->logPriority($level)\nMail::Message->logPriority($level)\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->logSettings()\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->notImplemented()\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->report( [$level] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->reportAll( [$level] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->shortSize( [$value] )\nMail::Message->shortSize( [$value] )\nRepresent an integer $value representing the size of file or memory, (which can be large)\ninto a short string using M and K (Megabytes and Kilobytes). Without $value, the size of the\nmessage head is used.\n\n$obj->shortString()\nConvert the message header to a short string (without trailing newline), representing the\nmost important facts (for debugging purposes only). For now, it only reports size and\nsubject.\n\n$obj->trace( [$level] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->warnings()\nInherited, see \"Error handling\" in Mail::Reporter\n"
                    },
                    {
                        "name": "Cleanup",
                        "content": "Extends \"Cleanup\" in Mail::Reporter.\n\n$obj->DESTROY()\nInherited, see \"Cleanup\" in Mail::Reporter\n\n$obj->destruct()\nRemove the information contained in the message object. This will be ignored when more than\none reference to the same message object exists, because the method has the same effect as\nassigning \"undef\" to the variable which contains the reference. Normal garbage collection\nwill call \"DESTROY()\" when possible.\n\nThis method is only provided to hide differences with messages which are located in folders:\ntheir Mail::Box::Message::destruct() works quite differently.\n\nexample: of Mail::Message destruct\n\nmy $msg = Mail::Message->read;\n$msg->destruct;\n$msg = undef;    # same\n"
                    }
                ]
            },
            "DETAILS": {
                "content": "",
                "subsections": [
                    {
                        "name": "Structure of a Message",
                        "content": "A MIME-compliant message is build upon two parts: the *header* and the *body*.\n\nThe header\nThe header is a list of fields, some spanning more than one line (*folded*) each telling\nsomething about the message. Information stored in here are for instance the sender of the\nmessage, the receivers of the message, when it was transported, how it was transported, etc.\nHeaders can grow quite large.\n\nIn MailBox, each message object manages exactly one header object (a Mail::Message::Head) and\none body object (a Mail::Message::Body). The header contains a list of header fields, which are\nrepresented by Mail::Message::Field objects.\n\nThe body\nThe body contains the \"payload\": the data to be transferred. The data can be encoded, only\naccessible with a specific application, and may use some weird character-set, like Vietnamese;\nthe MailBox distribution tries to assist you with handling these e-mails without the need to\nknow all the details. This additional information (\"meta-information\") about the body data is\nstored in the header. The header contains more information, for instance about the message\ntransport and relations to other messages.\n"
                    },
                    {
                        "name": "Message object implementation",
                        "content": "The general idea about the structure of a message is\n\nMail::Message\n|  |\n|  `-has-one--Mail::Message::Body\n|\n`----has-one--Mail::Message::Head\n|\n`-has-many--Mail::Message::Field\n\nHowever: there are about 7 kinds of body objects, 3 kinds of headers and 3 kinds of fields. You\nwill usually not see too much of these kinds, because they are merely created for performance\nreasons and can be used all the same, with the exception of the multipart bodies.\n\nA multipart body is either a Mail::Message::Body::Multipart (mime type \"multipart/*\") or a\nMail::Message::Body::Nested (mime type \"message/rfc822\"). These bodies are more complex:\n\nMail::Message::Body::Multipart\n|\n`-has-many--Mail::Message::Part\n|  |\n|  `-has-one--Mail::Message::Body\n|\n`----has-one--Mail::Message::Head\n\nBefore you try to reconstruct multiparts or nested messages yourself, you can better take a look\nat Mail::Message::Construct::Rebuild.\n"
                    },
                    {
                        "name": "Message class implementation",
                        "content": "The class structure of messages is very close to that of folders. For instance, a\nMail::Box::File::Message relates to a Mail::Box::File folder.\n\nAs extra level of inheritance, it has a Mail::Message, which is a message without location. And\nthere is a special case of message: Mail::Message::Part is a message encapsulated in a multipart\nbody.\n\nThe message types are:\n\nMail::Box::Mbox::Message            Mail::Box::POP3::Message\n|  Mail::Box::Dbx::Message      Mail::Box::IMAP4::Message  |\n|  |                                                    |  |\nMail::Box::File::Message             Mail::Box::Net::Message\n|                                      |\n|       Mail::Box::Maildir::Message    |\n|       |   Mail::Box::MH::Message     |\n|       |   |                          |\n|       Mail::Box::Dir::Message        |\n|                |                     |\n`------------.   |   .-----------------'\n|   |   |\nMail::Box::Message    Mail::Message::Part\n|                     |\n|       .-------------'\n|       |\nMail::Message\n|\n|\nMail::Reporter (general base class)\n\nBy far most folder features are implemented in Mail::Box, so available to all folder types.\nSometimes, features which appear in only some of the folder types are simulated for folders that\nmiss them, like sub-folder support for MBOX.\n\nTwo strange other message types are defined: the Mail::Message::Dummy, which fills holes in\nMail::Box::Thread::Node lists, and a Mail::Box::Message::Destructed, this is an on purpose\ndemolished message to reduce memory consumption.\n"
                    },
                    {
                        "name": "Labels",
                        "content": "Labels (also named \"Flags\") are used to indicate some special condition on the message, primary\ntargeted on organizational issues: which messages are already read or should be deleted. There\nis a very strong user relation to labels.\n\nThe main complication is that each folder type has its own way of storing labels. To give an\nindication: MBOX folders use \"Status\" and \"X-Status\" header fields, MH uses a \".mh-sequences\"\nfile, MAILDIR encodes the flags in the message's filename, and IMAP has flags as part of the\nprotocol.\n\nBesides, some folder types can store labels with user defined names, where other lack that\nfeature. Some folders have case-insensitive labels, other don't. Read all about the specifics in\nthe manual page of the message type you actually have.\n\nPredefined labels\nTo standardize the folder types, MailBox has defined the following labels, which can be used\nwith the label() and labels() methods on all kinds of messages:\n\n*   deleted\n\nThis message is flagged to be deleted once the folder closes. Be very careful about the\nconcept of 'delete' in a folder context : it is only a flag, and does not involve immediate\naction! This means, for instance, that the memory which is used by Perl to store the message\nis not released immediately (see destruct() if you need to).\n\nThe methods delete(), deleted(), and isDeleted() are only short-cuts for managing the\n\"delete\" label (as of MailBox 2.052).\n\n*   draft\n\nThe user has prepared this message, but is has not been send (yet). This flag is not\nautomatically added to a message by MailBox, and has only a meaning in user applications.\n\n*   flagged\n\nMessages can be *flagged* for some purpose, for instance as result of a search for spam in a\nfolder. The Mail::Box::messages() method can be used to collect all these flagged messages\nfrom the folder.\n\nProbably it is more useful to use an understandable name (like \"spam\") for these selections,\nhowever these self-defined labels can not stored in all folder types.\n\n*   old\n\nThe message was already in the folder when it was opened the last time, so was not recently\nadded to the folder. This flag will never automatically be set by MailBox, because it would\nprobably conflict with the user's idea of what is old.\n\n*   passed\n\nNot often used or kept, this flag indicates that the message was bounced or forwarded to\nsomeone else.\n\n*   replied\n\nThe user (or application) has sent a message back to the sender of the message, as response\nof this one. This flag is automatically set if you use reply(), but not with forward() or\nbounce().\n\n*   seen\n\nWhen this flag is set, the receiver of the message has consumed the message. A mail user\nagent (MUA) will set this flag when the user has opened the message once.\n\nStatus and X-Status fields\nMbox folders have no special means of storing information about messages (except the message\nseparator line), and therefore have to revert to adding fields to the message header when\nsomething special comes up. This feature is also enabled for POP3, although whether that works\ndepends on the POP server.\n\nAll applications which can handle mbox folders support the \"Status\" and \"X-Status\" field\nconvensions. The following encoding is used:\n\nFlag   Field       Label\nR      Status   => seen    (Read)\nO      Status   => old     (not recent)\nA      X-Status => replied (Answered)\nF      X-Status => flagged\n\nThere is no special flag for \"deleted\", which most other folders support: messages flagged to be\ndeleted will never be written to a folder file when it is closed.\n"
                    }
                ]
            },
            "DIAGNOSTICS": {
                "content": "Error: Cannot coerce a $class object into a $class object\nError: Cannot include forward source as $include.\nUnknown alternative for the forward(include). Valid choices are \"NO\", \"INLINE\", \"ATTACH\",\nand \"ENCAPSULATE\".\n\nError: Cannot include reply source as $include.\nUnknown alternative for the \"include\" option of reply(). Valid choices are \"NO\", \"INLINE\",\nand \"ATTACH\".\n\nError: Method bounce requires To, Cc, or Bcc\nThe message bounce() method forwards a received message off to someone else without\nmodification; you must specified it's new destination. If you have the urge not to specify\nany destination, you probably are looking for reply(). When you wish to modify the content,\nuse forward().\n\nError: Method forwardAttach requires a preamble\nError: Method forwardEncapsulate requires a preamble\nError: No address to create forwarded to.\nIf a forward message is created, a destination address must be specified.\n\nError: No default mailer found to send message.\nThe message send() mechanism had not enough information to automatically find a mail\ntransfer agent to sent this message. Specify a mailer explicitly using the \"via\" options.\n\nError: No rebuild rule $name defined.\nError: Only build() Mail::Message's; they are not in a folder yet\nYou may wish to construct a message to be stored in a some kind of folder, but you need to\ndo that in two steps. First, create a normal Mail::Message, and then add it to the folder.\nDuring this Mail::Box::addMessage() process, the message will get coerce()-d into the right\nmessage type, adding storage information and the like.\n\nError: Package $package does not implement $method.\nFatal error: the specific package (or one of its superclasses) does not implement this\nmethod where it should. This message means that some other related classes do implement this\nmethod however the class at hand does not. Probably you should investigate this and probably\ninform the author of the package.\n\nError: coercion starts with some object\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "This module is part of Mail-Message distribution version 3.012, built on February 11, 2022.\nWebsite: http://perl.overmeer.net/CPAN/\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself. See http://dev.perl.org/licenses/\n",
                "subsections": []
            }
        }
    }
}