J
Joe Hasting
I am re-posting to see if anyone has a suggestion, or experience using this
module.:
------------------------------------------------------
I would like to use the IMAP:Simple module to poll a IMAP server. I want to
look at messages and search the subject and body for a string. I got the
sample script from CPAN (below), but I can't get it to work. I changed
someserver to my IMAP server, and someuser, somepassword, and somefolder to
the appropriate values, but when I run it it returns immediatly with no
responce (I can use a mail client and see me mesages in the folder on my
IMAP server). Can someone let me know how I can check to see if I am
logging into the server, or an alternate method that has worked for use to
read IMAP.
thanks
J
use Net::IMAP::Simple;
# open a connection to the IMAP server
$server = new Net::IMAP::Simple( $self->param( 'someserver' ) );
# login
$server->login( 'someuser', 'somepassword' );
# select the desired folder
$number_of_messages = select( 'somefolder' );
# go through all the messages in the selected folder
foreach $msg ( 1..$number_of_messages ) {
# get the message
$lines = $server->get( $msg );
# print it
print @$lines;
}
# the list of all folders
@folders = $server->mailboxes();
# create a folder
$server->create_mailbox( 'newfolder' );
# rename a folder
$server->rename_mailbox( 'newfolder', 'renamedfolder' );
# delete a folder
$server->delete_mailbox( 'renamedfolder' );
# copy a message to another folder
$server->copy( $self, $msg, 'renamedfolder' );
# close the connection
$server->quit();
module.:
------------------------------------------------------
I would like to use the IMAP:Simple module to poll a IMAP server. I want to
look at messages and search the subject and body for a string. I got the
sample script from CPAN (below), but I can't get it to work. I changed
someserver to my IMAP server, and someuser, somepassword, and somefolder to
the appropriate values, but when I run it it returns immediatly with no
responce (I can use a mail client and see me mesages in the folder on my
IMAP server). Can someone let me know how I can check to see if I am
logging into the server, or an alternate method that has worked for use to
read IMAP.
thanks
J
use Net::IMAP::Simple;
# open a connection to the IMAP server
$server = new Net::IMAP::Simple( $self->param( 'someserver' ) );
# login
$server->login( 'someuser', 'somepassword' );
# select the desired folder
$number_of_messages = select( 'somefolder' );
# go through all the messages in the selected folder
foreach $msg ( 1..$number_of_messages ) {
# get the message
$lines = $server->get( $msg );
# print it
print @$lines;
}
# the list of all folders
@folders = $server->mailboxes();
# create a folder
$server->create_mailbox( 'newfolder' );
# rename a folder
$server->rename_mailbox( 'newfolder', 'renamedfolder' );
# delete a folder
$server->delete_mailbox( 'renamedfolder' );
# copy a message to another folder
$server->copy( $self, $msg, 'renamedfolder' );
# close the connection
$server->quit();