http://www.perlmonks.org?node_id=1086093

Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:

I'm on OSX and I can send mail directly to my user account using simply <username>@<ipaddress> as the address.

This is the kind of classic email you would read using pine or elm or something. "You have new mail from cron in /var/spool/mail/root" -style email.

How would I read mail that using Perl?

Replies are listed 'Best First'.
Re: How to read local unix-style mail
by LanX (Saint) on May 15, 2014 at 00:40 UTC
    When do you want to read the mails?

    Do you want to poll several of them out of the inbox every interval or do you want to trigger a process instantly for each incoming mail? For the latter see procmail and family.

    For the rest see The Evolution of Perl Email Handling (I googled it for you :)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re: How to read local unix-style mail
by hippo (Bishop) on May 15, 2014 at 08:18 UTC

    It depends how fully-functional you want your "read" operation to be. Towards the top end of the scale is Mail::Box::Mbox - but if you think that's overkill then you'll have to be a bit more specific about how you want to "read" it and what other operations should be involved.

Re: How to read local unix-style mail
by ww (Archbishop) on May 15, 2014 at 00:43 UTC

    If there's really some reason pine and relatives won't do, you might start by searching CPAN using "mail" as a keyword.


    Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
    1. code
    2. verbatim error and/or warning messages
    3. a coherent explanation of what "doesn't work actually means.

    check Ln42!