{
    "content": [
        {
            "type": "text",
            "text": "# mail (perldoc)\n\n## Sections\n\n- **Found in /usr/share/perl/5.34/pod/perlfaq2.pod**\n- **Found in /usr/share/perl/5.34/pod/perlfaq9.pod**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "mail",
        "section": "-q",
        "mode": "perldoc",
        "summary": null,
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "Found in /usr/share/perl/5.34/pod/perlfaq2.pod",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "Found in /usr/share/perl/5.34/pod/perlfaq9.pod",
                "lines": 122,
                "subsections": []
            }
        ],
        "sections": {
            "Found in /usr/share/perl/5.34/pod/perlfaq2.pod": {
                "content": "What mailing lists are there for Perl?\nA comprehensive list of Perl-related mailing lists can be found at\n<http://lists.perl.org/>\n",
                "subsections": []
            },
            "Found in /usr/share/perl/5.34/pod/perlfaq9.pod": {
                "content": "How do I parse a mail header?\nUse the Email::MIME module. It's well-tested and supports all the\ncraziness that you'll see in the real world (comment-folding whitespace,\nencodings, comments, etc.).\n\nuse Email::MIME;\n\nmy $message = Email::MIME->new($rfc2822);\nmy $subject = $message->header('Subject');\nmy $from    = $message->header('From');\n\nIf you've already got some other kind of email object, consider passing\nit to Email::Abstract and then using its cast method to get an\nEmail::MIME object:\n\nmy $abstract = Email::Abstract->new($mailmessageobject);\nmy $emailmimeobject = $abstract->cast('Email::MIME');\n\nHow do I check a valid mail address?\n(partly contributed by Aaron Sherman)\n\nThis isn't as simple a question as it sounds. There are two parts:\n\na) How do I verify that an email address is correctly formatted?\n\nb) How do I verify that an email address targets a valid recipient?\n\nWithout sending mail to the address and seeing whether there's a human\non the other end to answer you, you cannot fully answer part *b*, but\nthe Email::Valid module will do both part *a* and part *b* as far as you\ncan in real-time.\n\nOur best advice for verifying a person's mail address is to have them\nenter their address twice, just as you normally do to change a password.\nThis usually weeds out typos. If both versions match, send mail to that\naddress with a personal message. If you get the message back and they've\nfollowed your directions, you can be reasonably assured that it's real.\n\nA related strategy that's less open to forgery is to give them a PIN\n(personal ID number). Record the address and PIN (best that it be a\nrandom one) for later processing. In the mail you send, include a link\nto your site with the PIN included. If the mail bounces, you know it's\nnot valid. If they don't click on the link, either they forged the\naddress or (assuming they got the message) following through wasn't\nimportant so you don't need to worry about it.\n\nHow do I find the user's mail address?\nAsk them for it. There are so many email providers available that it's\nunlikely the local system has any idea how to determine a user's email\naddress.\n\nThe exception is for organization-specific email (e.g.\nfoo@yourcompany.com) where policy can be codified in your program. In\nthat case, you could look at $ENV{USER}, $ENV{LOGNAME}, and getpwuid($<)\nin scalar context, like so:\n\nmy $username = getpwuid($<)\n\nBut you still cannot make assumptions about whether this is correct,\nunless your policy says it is. You really are best off asking the user.\n\nHow do I send email?\nUse the Email::Stuffer module, like so:\n\n# first, create your message\nmy $message = Email::Stuffer->from('you@example.com')\n->to('friend@example.com')\n->subject('Happy birthday!')\n->textbody(\"Happy birthday to you!\\n\");\n\n$message->sendordie;\n\nBy default, Email::Sender::Simple (the \"send\" and \"sendordie\" methods\nuse this under the hood) will try \"sendmail\" first, if it exists in your\n$PATH. This generally isn't the case. If there's a remote mail server\nyou use to send mail, consider investigating one of the Transport\nclasses. At time of writing, the available transports include:\n\nEmail::Sender::Transport::Sendmail\nThis is the default. If you can use the mail(1) or mailx(1) program\nto send mail from the machine where your code runs, you should be\nable to use this.\n\nEmail::Sender::Transport::SMTP\nThis transport contacts a remote SMTP server over TCP. It optionally\nuses TLS or SSL and can authenticate to the server via SASL.\n\nTelling Email::Stuffer to use your transport is straightforward.\n\n$message->transport($emailsendertransportobject)->sendordie;\n\nHow do I use MIME to make an attachment to a mail message?\nEmail::MIME directly supports multipart messages. Email::MIME objects\nthemselves are parts and can be attached to other Email::MIME objects.\nConsult the Email::MIME documentation for more information, including\nall of the supported methods and examples of their use.\n\nEmail::Stuffer uses Email::MIME under the hood to construct messages,\nand wraps the most common attachment tasks with the simple \"attach\" and\n\"attachfile\" methods.\n\nEmail::Stuffer->to('friend@example.com')\n->subject('The file')\n->attachfile('stuff.csv')\n->sendordie;\n\nHow do I read email?\nUse the Email::Folder module, like so:\n\nuse Email::Folder;\n\nmy $folder = Email::Folder->new('/path/to/email/folder');\nwhile(my $message = $folder->nextmessage) {\n# nextmessage returns Email::Simple objects, but we want\n# Email::MIME objects as they're more robust\nmy $mime = Email::MIME->new($message->asstring);\n}\n\nThere are different classes in the Email::Folder namespace for\nsupporting various mailbox types. Note that these modules are generally\nrather limited and only support reading rather than writing.\n",
                "subsections": []
            }
        }
    }
}