Hello morgon,

I used the below quick program to access gmail account via IMAP. The module I use is Net::IMAP::Simple and it's docs tell us that the search in IMAP is defined in RFC 5256. The module has the capability to search but a a quick (read: no exhaustive) serach seems to suggest that gmail doesn't support RFC 5256. Anyway I confirm that the only search that runs ok with gmail is $imap->search("ALL")

use strict; use warnings; # required modules use Net::IMAP::Simple; use Email::Simple; use IO::Socket::SSL; use HTML::Strip; use Data::Dump; # fill in your details here my $username = 'my_account_of_gmail@gmail.com'; my $password = $ARGV[0] || die "password as first argument!"; my $mailhost = 'pop.gmail.com'; # Connect my $imap = Net::IMAP::Simple->new( $mailhost, port => 993, use_ssl => 1, ) || die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n"; my $hs = HTML::Strip->new(); # Log in if ( !$imap->login( $username, $password ) ) { print STDERR "Login failed: " . $imap->errstr . "\n"; exit(64); } # Look in the the INBOX my $nm = $imap->select('INBOX'); # How many messages are there? my ($unseen, $recent, $num_messages) = $imap->status(); print "unseen: $unseen, recent: $recent, total: $num_messages\n\n"; ## Iterate through unseen messages for ( my $i = 1 ; $i <= $nm ; $i++ ) { #last if $i == 2; if ( $imap->seen($i) ) { next; } else { my $es = Email::Simple->new( join '', @{ $imap->get($i) } ); printf( "[%03d] %s\n", $i, $es->header('From'), $es->header('Subje +ct')); #print "BODY[".$es->body."]\n\n"; print "Cc-------------->", $es->header('Cc'),"\nTo------>",$es->he +ader('To'),"\n"; #dd $es; print $hs->parse( $es->body ); print +('=' x 70),"\n"; } } # Disconnect $imap->quit; exit;

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: imap problem with gmail -- RFC 5256 by Discipulus
in thread imap problem with gmail by morgon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.