Search code examples
perlimap

can't locate object method "see" via package "Net::IMAP::Simple"


I am trying to fetch unread emails from server and mark them as seen (read) after fetching. I'm using perl script and the package Net::IMAP::Simple. I'm writing this script for the office work.

Below is some code :

use strict;    
use warnings;
use Net::IMAP::Simple;
use Email::Simple;
use HTTP::Date;
#some code....

# Create the object
my $server = Net::IMAP::Simple->new($imap_server) or die "Can't connect to server: $imap_server ";

# Log on
my $login = $server->login($imap_user,$imap_passwd) or die "Login failed (bad username or password)";

#some code.....

# set the message as seen
$server->see($i);

# i also used $server->add_flags($i,'\Seen'); but it throws same error.

The Irony is, this code works fine on my Gmail account , which i use for testing. but when i test it in office it throws error ;

can't locate object method "see" via package "Net::IMAP::Simple"

I don't know what's the issue here.


Solution

  • The methods see and unsee were added in Net::IMAP::Simple version 1.1899_05.

    > 1.1899_05: Tue Jun 16 06:42:16 EDT 2009
    >    - I started working on ticket 45953,
    >    - created sub_flags() and add_flags()
    >    - taught delete() to use add_flags() -- adds \Deleted
    >    - providing see() and unsee() for ticket 45953
    >    - I started building tests for the flag manipulation stuff and
    >      put reselect stuff ... noticed a possible bug in
    >      Net::IMAP::Server
    

    You likely have an older version on your production system. Update it, and include a minimum version in your Makefile.PL or cpanfile or whatever you use to track dependencies.