Mail::Transport::IMAP4 - proxy to Mail::IMAPClient |
Mail::Transport::IMAP4 - proxy to Mail::IMAPClient
Mail::Transport::IMAP4 is a Mail::Transport::Receive is a Mail::Transport is a Mail::Reporter
my $imap = Mail::Transport::IMAP4->new(...); my $message = $imap->receive($id); $imap->send($message);
****** UNDER DEVELOPMENT *****, please help testing
The IMAP4 protocol is quite complicated: it is feature rich and allows verious asynchronous actions. The main document describing IMAP is rfc3501 (which obsoleted the original specification of protocol 4r1 in rfc2060 in March 2003).
This package, as part of MailBox, does not implement the actual protocol itself but uses Mail::IMAPClient to do the work. The task for this package is to hide as many differences between that module's interface and the common Mail::Box folder types. Multiple Mail::Box::IMAP4 folders can share one Mail::Transport::IMAP4 connection.
$obj->url
Represent this imap4 connection as URL.
Mail::Transport::IMAP4->new(OPTIONS)
Create the IMAP connection to the server. IMAP servers can handle multiple folders for a single user, which means that connections may get shared. This is sharing is hidden for the user.
When an imap_client
is specified, then the options hostname
,
port
, username
, and password
are extracted from it.
Option Defined in Default authenticate C<'AUTO'> domain <server_name> executable L<Mail::Transport> C<undef> hostname L<Mail::Transport> C<'localhost'> imap_client L<Mail::IMAPClient|Mail::IMAPClient> interval L<Mail::Transport> C<30> log L<Mail::Reporter> C<'WARNINGS'> password L<Mail::Transport> undef port L<Mail::Transport> 143 proxy L<Mail::Transport> undef retry L<Mail::Transport> <false> timeout L<Mail::Transport> C<120> trace L<Mail::Reporter> C<'WARNINGS'> username L<Mail::Transport> undef via L<Mail::Transport> C<'imap'>
. authenticate TYPE|ARRAY-OF-TYPES
Authenthication method to login(), which will be passed to the Mail::IMAPClient manpage method authenticate(). See the latter method for the available types.
. domain WINDOWS_DOMAIN
Used for NTLM authentication.
. executable FILENAME
. hostname HOSTNAME|ARRAY-OF-HOSTNAMES
. imap_client OBJECT|CLASS
When an OBJECT is supplied, that client will be used for the implementation of the IMAP4 protocol. Information about server and such are extracted from the OBJECT to have the accessors to produce correct results. The OBJECT shall be a Mail::IMAPClient.
When a CLASS is given, an object of that type is created for you. The created object can be retreived via imapClient(), and than configured as defined by Mail::IMAPClient.
. interval SECONDS
. log LEVEL
. password STRING
. port INTEGER
. proxy PATH
. retry NUMBER|undef
. timeout SECONDS
. trace LEVEL
. username STRING
. via CLASS|NAME
$obj->receive([UNIQUE-MESSAGE-ID])
See Receiving mail in the Mail::Transport::Receive manpage
$obj->findBinary(NAME [, DIRECTORIES])
See Server connection in the Mail::Transport manpage
$obj->remoteHost
See Server connection in the Mail::Transport manpage
$obj->retry
See Server connection in the Mail::Transport manpage
$obj->authentication(['AUTO'|TYPE|LIST-OF-TYPES])
Returned is a list of pairs (ref arrays) each describing one possible
way to contact the server. Each pair contains a mechanism name and
a challange callback (which may be undef
).
The settings are used by login() to get server access. The initial value origins from new(authenticate), but may be changed later.
Available basic TYPES are CRAM-MD5
and PLAIN
. The latter is sending
username and password in plain text, and is therefore tried as last
resort.
The NTLM
authentication requires Authen::NTLM to be installed. Other
methods may be added later. Besides, you may also specify a CODE
reference which implements some authentication.
When AUTO
is given, then CRAM-MD5
, NTLM
and PLAIN
are tried,
in that specific order. When the Authen::NTLM is not installed it
will silently be skipped. Be warned that, because of PLAIN
, erroneous
username/password combinations will be passed readible as last attempt!
An ARRAY as TYPE can be used to specify both mechanism as callback. When
no array is used, callback of the pair is set to undef
. See
authenticate in the Mail::IMAPCleint manpage for the gory details.
Example:
$transporter->authentication('CRAM-MD5', [MY_AUTH => \&c], 'PLAIN');
foreach my $pair ($transporter->authentication) { my ($mechanism, $challange) = @$pair; ... }
$obj->domain([DOMAIN])
Used in NTLM authentication to define the Windows domain which is accessed. Initially set by new(domain) and defaults to the server's name.
The follow methods handle protocol internals, and should not be used by a normal user of this class.
$obj->appendMessage(MESSAGE, FOLDERNAME)
Write the message to the server.
$obj->createImapClient(CLASS)
Create an object of CLASS, which extends the Mail::IMAPClient manpage.
$obj->deleteFolder(NAME)
Remove one folder.
$obj->destroyDeleted
Command the server to delete for real all messages which are flagged to be deleted.
$obj->fetch(ARRAY-OF-MESSAGES, INFO)
Get some INFO about the MESSAGES from the server. The specified messages
shall extend Mail::Box::Net::Message, Returned is a list
of hashes, each info about one result. The contents of the hash
differs per INFO, but at least a message
field will be present, to
relate to the message in question.
The right folder should be selected before this method is called. When
the connection was lost, undef
is returned. Without any
messages, and empty array is returned. The retrieval is done by
Mail::IMAPClient method fetch()
, which is then
parsed.
$obj->flagsToLabels(WHAT|FLAGS)
Mail::Transport::IMAP4->flagsToLabels(WHAT|FLAGS)
In SCALAR context, a hash with labels is returned. In LIST context, pairs are returned.
The WHAT parameter can be 'SET'
, 'CLEAR'
, or 'REPLACE'
. With the
latter, all standard imap flags do not appear in the list will be ignored:
their value may either by set or cleared. See getFlags()
Unknown flags in LIST are stripped from their backslash and lower-cased. For instance, '\SomeWeirdFlag' will become `someweirdflag => 1'.
Example: translating IMAP4 flags into MailBox flags
my @flags = ('\Seen', '\Flagged'); my $labels = Mail::Transport::IMAP4->flags2labels(SET => @flags);
$obj->folder([FOLDERNAME])
Be sure that the specific FOLDER is the current one selected. If the folder is already selected, no IMAP traffic will be produced. The imap connection is returned on succes
$obj->folders([FOLDERNAME])
Returns a list of folder names which are sub-folders of the specified FOLDERNAME. Without FOLDERNAME, the top-level foldernames are returned.
$obj->getFields(UID, NAME, [NAME, ...])
Get the records with the specified NAMES from the header. The header
fields are returned as list of Mail::Message::Field::Fast objects.
When the name is ALL
, the whole header is returned.
$obj->getFlags(FOLDER, ID)
Returns the values of all flags which are related to the message with the specified ID. These flags are translated into the names which are standard for the MailBox suite.
A HASH is returned. Names which do not appear will also provide a value in the returned: the negative for the value is it was present.
$obj->getMessageAsString(MESSAGE|UID)
Returns the whole text of the specified message: the head and the body.
$obj->ids
Returns a list of UIDs which are defined by the IMAP server.
$obj->imapClient
Returns the object which implements the IMAP4 protocol, an instance of a Mail::IMAPClient, which is logged-in and ready to use.
If the contact to the server was still present or could be established,
an Mail::IMAPClient object is returned. Else, undef
is returned and
no further actions should be tried on the object.
$obj->labelsToFlags(HASH|PAIRS)
Mail::Transport::IMAP4->labelsToFlags(HASH|PAIRS)
Convert MailBox labels into IMAP flags. Returned is a string. Unsupported labels are ignored.
$obj->listFlags
Returns all predefined flags as list.
$obj->login
Establish a new connection to the IMAP4 server, using username and password.
$obj->setFlags(ID, LABEL, VALUE, [LABEL, VALUE], ...)
Change the flags on the message which are represented by the label. The value which can be related to the label will be lost, because IMAP only defines a boolean value, where MailBox labels can contain strings.
Returned is a list of LABEL=>VALUE pairs which could not be send to the IMAP server. These values may be cached in a different way.
$obj->AUTOLOAD
See Error handling in the Mail::Reporter manpage
$obj->addReport(OBJECT)
See Error handling in the Mail::Reporter manpage
$obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
Mail::Transport::IMAP4->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
See Error handling in the Mail::Reporter manpage
$obj->errors
See Error handling in the Mail::Reporter manpage
$obj->log([LEVEL [,STRINGS]])
Mail::Transport::IMAP4->log([LEVEL [,STRINGS]])
See Error handling in the Mail::Reporter manpage
$obj->logPriority(LEVEL)
Mail::Transport::IMAP4->logPriority(LEVEL)
See Error handling in the Mail::Reporter manpage
$obj->logSettings
See Error handling in the Mail::Reporter manpage
$obj->notImplemented
See Error handling in the Mail::Reporter manpage
$obj->report([LEVEL])
See Error handling in the Mail::Reporter manpage
$obj->reportAll([LEVEL])
See Error handling in the Mail::Reporter manpage
$obj->trace([LEVEL])
See Error handling in the Mail::Reporter manpage
$obj->warnings
See Error handling in the Mail::Reporter manpage
$obj->DESTROY
The connection is cleanly terminated when the program is terminated.
$obj->inGlobalDestruction
See Cleanup in the Mail::Reporter manpage
Error: Cannot connect to $host:$port for IMAP4: $!
Error: IMAP cannot connect to $host: $@
Notice: IMAP4 authenication $mechanism to $host:$port successful
Error: IMAP4 requires a username and password
Error: IMAP4 username $username requires a password
Error: Package $package does not implement $method.
Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package.
Error: module Authen::NTLM is not installed
You try to establish an IMAP4 connection which explicitly uses NTLM authentication, but the optional Authen::NTLM, which implements this is not installed on your system.
See the MailBox website at http://perl.overmeer.net/mailbox/ for more details.
Distribution version 2.059. Written by Mark Overmeer (mark@overmeer.net) See the ChangeLog for other contributors.
Copyright (c) 2001-2003 by the author(s). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Mail::Transport::IMAP4 - proxy to Mail::IMAPClient |