Net::I...:Simple(3pm)
π NAME π
Okay bestie, listen: Net::IMAP::Simple is a Perl extension for simple IMAP account handling. Thatβs the whole assignment. Itβs giving βI just want to talk to my IMAP server without a whole dramatic saga,β and honestly? Iconic. π
π SYNOPSIS π
Hereβs the vibe in code form β literally the whole little group-chat intro:
use strict;
use warnings;
use Net::IMAP::Simple;
use Email::Simple;
# Create the object
my $imap = Net::IMAP::Simple->new('imap.example.com') ||
die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n";
# Log on
if(!$imap->login('user','pass')){
print STDERR "Login failed: " . $imap->errstr . "\n";
exit(64);
}
# Print the subject's of all the messages in the INBOX
my $nm = $imap->select('INBOX');
for(my $i = 1; $i <= $nm; $i++){
if($imap->seen($i)){
print "*";
} else {
print " ";
}
my $es = Email::Simple->new(join '', @{ $imap->top($i) } );
printf("[%03d] %s\n", $i, $es->header('Subject'));
}
$imap->quit;
π¦ DESCRIPTION π¦
This module is a simple way to access IMAP accounts. No cap β itβs literally the low-drama route to IMAP. β¨
β¨ OBJECT CREATION METHOD β¨
my $imap = Net::IMAP::Simple->new( $server [ :port ]);
# OR
my $imap = Net::IMAP::Simple->new( $server [, option_name => option_value ] );
π new π
This class method constructs a new Net::IMAP::Simple object. It takes one required parameter β the server to connect to β plus additional optional parameters. π«Ά
The server parameter may specify just the server, or both the server and port number. To specify an alternate port, separate it from the server with a colon (:), like example.com:5143.
On success an object is returned. On failure, nothing is returned and an error message is set to $Net::IMAP::Simple.
See βPREAUTHβ below for a special hostname invocation that doesnβt use Sockets (internally).
Options are provided as a hash to new():
port => intβ assign the port number (default:143).timeout => intβ connection timeout in seconds (default:90).retry => intβ attempt to retry the connection attempt (x) times before giving up (default:1).retry_delay => intβ wait (x) seconds before retrying a connection attempt (default:5).use_v6 => BOOLβ if set to true, attempt to use IPv6 sockets rather than IPv4 sockets. This option requires theIO::Socket::INET6module.use_ssl => BOOLβ if set to true, attempt to useIO::Socket::SSLsockets rather than vanilla sockets. Note that no attempt is made to check the certificate validity by default. This is terrible personal security but matches the previous behavior of this module. Please consider usingfind_ssl_defaultsbelow. This option requires theIO::Socket::SSLmodule.ssl_version => versionβ this should be one or more of the following (space separated):SSLv3SSLv2TLSv1. If you specify, for example,SSLv3 SSLv2, thenIO::Socket::SSLwill attempt auto negotiation. At the time of this writing, the default string was v3/v2 auto negotiation β it may have changed by the time you read this. β οΈ Warning: setting this will also setuse_ssl.find_ssl_defaults => []β looks in some standard places for CA certificate libraries and, if found, sets reasonable defaults along the lines of the following:
ssl_options => [ SSL_ca_path => "/etc/ssl/certs/",
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_PEER() ]
β οΈ Warning: setting this will also set use_ssl.
ssl_options => []β you may provide your ownIO::Socket::SSLoptions if you desire to do so. It is completely overridden byfind_ssl_defaultsabove.bindaddr => strβ assign a local address to bind.use_select_cache => BOOLβ enableselect()caching internally.select_cache_ttl => intβ the number of seconds to allow a select cache result live before running$imap->select()again.debug => BOOL | \*HANDLE | warn | file:nameβ enable debugging output. If\*HANDLEis a valid file handle, debugging will be written to it. If it is the stringwarn, then the debugging will be written using thewarncommand. If it is a string of the formfile:name, then the named file will be opened for append and the debugs written to it. Otherwise debugging will be written toSTDOUT.readline_callback => CODEβ you may choose to pass a callback function for the purpose of pre-processing lines before they are handed to the rest of theNet::IMAP::Simpleinternals. This can be handy for animating a spinner or modifying the IMAP behavior.
π PREAUTH π
Rather than passing a port number and issuing a login, in some situations it may be convenient to authenticate with (for example) ssh and simply invoke (for example) dovecot by hand.
If the server name starts with cmd:, then Net::IMAP::Simple will issue the command rather than building sockets. This is a typical setup:
my $cmd = "ssh -C mailhost dovecot --exec-mail imap";
my $imap = Net::IMAP::Simple->new("cmd:$cmd");
# $imap->login(); ... don't need this
my $number_of_messages = $imap->select("INBOX");
πΈ METHODS πΈ
π§ starttls π§
$imap->starttls;
If you start an IMAP session and wish to upgrade to SSL later, you can use this function to start TLS. This function will try to require IO::Socket::SSL and Net::SSLeay at runtime. π«
π login π
my $inbox_msgs = $imap->login($user, $passwd);
This method takes two required parameters, a username and password. This pair is authenticated against the server. If authentication is successful, TRUE (1) will be returned.
Nothing is returned on failure and the errstr() error handler is set with the error message.
π¬ status π¬
my $num_messages = $imap->status($folder);
my ($unseen, $recent, $num_messages) = $imap->status($folder);
Issue a STATUS command. The STATUS command counts messages without altering the state of the named (optionally) mailbox. It returns either the number of messages, or the number of unseen messages, recent, and the total number of messages.
$folder is an optional argument. status() will use the current mailbox or INBOX if the $folder argument is not provided.
This method does not use caching.
This method can also query custom status values. The first argument to the function (if any) is assumed to be the folder name, so the folder argument is required when trying to query custom status values.
my ($f1, $f2) = $imap->status($folder, qw(f1 f2));
my $f2 = $imap->status($folder, qw(f1 f2));
π uidnext π
my $uidnext = $imap->uidnext($folder);
Return the UIDNEXT value for a mailbox. The $folder argument is optional. This is really just an alias for
my $uidnext = $imap->status($folder, qw(uidnext));
with the mild difference that it can compute the folder argument for you. π
πͺͺ uidvalidity πͺͺ
my $uidvalidity = $imap->uidnext($folder);
Return the UIDVALIDITY value for a mailbox. The $folder argument is optional. This is also an alias for the status call like uidnext() above.
π uid π
This function is actually an alias for $imap->uidsearch($msg_range).
my($uid)= $imap->uid($msgno);
my @uid = $imap->uid($msg_range); # eg 4:14 or 15,4,14
Return the UID value(s) for a message. These unique IDs must stay the same during the session and should stay the same between sessions. Whether they stay the same depends on the UIDVALIDITY value; see above and RFC3501.
β οΈ Warning: although you might think@uidshould contain theUIDs for15, then4, then14in the example above, most IMAP servers seem to return the UIDs in increasing order. Normally the sequence numbers are in increasing order also, so it all matches up.
my ($uid4, $uid14, $uid15) = $imap->uid("15,4,14"); # warning
One final note: this gives the size of the search match, not the uid like you might expect:
my $uid_search_result_list_size = $imap->uid('3'); # probably always 1
π’ seq π’
my $seq = $imap->seq($uids);
my @seq = $imap->seq($uids); # eg 58888:58900
Rather like uid() above, but maps uids to sequence numbers. π―
π select π
my $num_messages = $imap->select($folder);
Selects a folder named in the single required parameter. The number of messages in that folder is returned on success. On failure, nothing is returned and the errstr() error handler is set with the error message.
π examine π
This is very nearly a synonym for select(). The only real difference is that the EXAMINE command is sent to the server instead of SELECT. Net::IMAP::Simple is otherwise unaware of the read-only-ness of the mailbox.
πͺ close πͺ
$imap->close;
Un-selects the current mailbox, leaving no mailbox selected.
π messages π
print "Messages in Junk Mail -- " . $imap->messages("INBOX.Junk Mail") . "\n";
This method is an alias for $imap->select.
π© flags π©
print "Available server flags: " . join(", ", $imap->flags) . "\n";
This method accepts an optional folder name and returns the current available server flags as a list, for the selected folder. If no folder name is provided, the last folder $imap->select'ed will be used.
This method uses caching.
πͺ separator πͺ
Returns the folder separator (technically βhierarchy separatorβ, rfc3501Β§6.3.8) for the server.
π recent π
print "Recent messages value: " . $imap->recent . "\n";
This method accepts an optional folder name and returns the RECENT value provided during a SELECT result set. If no folder name is provided, the last folder $imap->select'ed will be used.
This method uses caching.
See also: search.
π unseen π
print "Unseen messages value: " . $imap->unseen . "\n";
This method accepts an optional folder name and returns the UNSEEN value provided during a SELECT command result. If no folder name is provided, the last folder $imap->select'ed will be used. If a folder name is provided, this will issue a SELECT first.
This method uses caching.
If the server does not provide UNSEEN during SELECT β surprisingly common β this method will fall back and use STATUS to determine the unseen count. π«Ά
π‘ quick note bestie: this is NOT the opposite ofseenbelow. The UNSEEN value varies from server to server, but per the IMAP spec it should be the number of the first unseen message β if the flag is even provided. (If it's not provided, you're stuck using theSEARCHcommand to find it. annoying, i know π)
See also: search.
current_box
print "Current Mail Box folder: " . $imap->current_box . "\n";
Returns the name of the mail box folder you're currently working in. that's it, that's the whole vibe π
top
my $header = $imap->top( $message_number ); print for @{$header};
Takes a message number as its required parameter, and pulls that message from the currently selected folder. On success you get a list reference holding the header lines. On failure you get nothing back and the errstr() error handler gets set with the error message. π
seen
defined( my $seen = $imap->seen( $message_number ) )
or warn "problem testing for \Seen: "
. $imap->errstr;
print "msg #$message_number has been \Seen!" if $seen;
A message number is the only thing you gotta pass. It checks the message's \Seen flag: true value back if the message has been seen, a defined false value if the \Seen flag isn't set, and the undefined value if something went wrong while checking the flag status.
β οΈ NOTE: this is not the opposite ofunseenup above. This one actually fires off aFETCHcommand and checks whether the given message has been\Seenbefore. different beast, same font.
deleted
defined( my $deleted = $imap->deleted( $message_number ) )
or warn "problem testing for \Deleted: "
. $imap->errstr;
print "msg #$message_number has been \Deleted!" if $deleted;
Same deal β message number, only required param. It looks at the \Deleted flag: true if the message has been deleted, a defined false value if the \Deleted flag isn't set, and undefined if there was an error checking the flag. π¦
list
my $message_size = $imap->list($message_number);
my $mailbox_sizes = $imap->list;
Gives you size info β for one message if you pass the single optional parameter, or for every message in a mailbox if you don't. Single message query = scalar value. Whole mailbox = a hash. On failure nothing comes back and errstr() gets the error message. π
fetch
my $headers = $imap->fetch("1:5")
Fetches the headers for messages 1-5 in the current folder. iconic.
for my $midx ( keys %$headers ) {
for my $hdr in ($headers->{$midx}) {
say "$hdr"
# In many situations the headers will be parsed and may not be simple
# strings (e.g., with the SimpleX RecDescent parse). The simplest
# way to get a feel for the output is to use a dumper on it.
}
}
get
my $message = $imap->get( $message_number ) or die $imap->errstr;
my @message_lines = $map->get( $message_number ) or die $imap->errstr;
my $part = $imap->get( $message_number, '1.1' ) or die $imap->errstr;
my @part_lines = $imap->get( $message_number, '1.1' ) or die $imap->errstr;
Fetches a message and returns its lines as an array β or the actual message. On failure you get an empty list and errstr() is set with the error message.
Optionally you can name a part to grab just a specific chunk of a message. That's the raw, encoded body of the part, bestie. The part number is a set of zero or more part specifiers separated by periods, and every message has at least one part. Passing a part of '1' returns the raw, encoded body β only useful if you already know the header info like the encoding. iykyk π§
π history lesson: get() used to return the array of lines as a reference to the array instead of returning the message or the array itself. It still does that, but heads up β it may get deprecated in the future.
The scalar result is actually a blessed arrayref with the stringify member overloaded. So if you're planning to use that message as a string more than once, forcing the stringification first is lowkey smart:
my $message = $imap->get(1);
$message = "$message"; # force stringification
That said, it's not normally necessary. don't stress it. β¨
put
$imap->put( $mailbox_name, $message, @flags ) or warn $imap->errstr;
Saves a message to the server under the folder named $mailbox_name. You can optionally pass flags for the mail (like \Seen, \Answered) β but they must start with a slash, fr fr.
If $message is an arrayref, the lines get printed correctly. slay.
put_with_date
$imap->put_with_date( $mailbox_name, $message, $date, @flags ) or warn $imap->errstr;
Same energy as put above β saves a message under the folder named $mailbox_name β but supplying a date sets the IMAP server's internal date for the message, if the server supports it per RFC 3501 Section 6.3.11.
πΈ heads up for Gmail besties: it expects the date formatDD-Mon-YYYY hh:mm:ss tzβ for example31-Dec-2016 12:59:59 -0500.
msg_flags
my @flags = $imap->msg_flags( $message_number );
my $flags = $imap->msg_flags( $message_number );
# aught to come out roughly the same
print "Flags on message #$message_number: @flags\n";
print "Flags on message #$message_number: $flags\n";
Catching errors with this one is usually what you want. In scalar context, error detection = testing for defined:
if( defined( my $flags = $imap->msg_flags($num) ) ) {
# it has $flags!
} else {
warn "problem listing flags for message #$num: "
. $imap->errstr;
}
In list context though, you must call waserr() to test for success:
my @flags = $imap->msg_flags($num);
warn "problem listing flags for msg #$num: "
. $imap->errstr if $imap->waserr;
getfh
my $file = $imap->getfh( $message_number ); print <$file>;
On success you get a file handle pointing at the message identified by the required parameter π«Ά. On failure nothing comes back and errstr() gets the error message.
quit
$imap->quit;
OR
$imap->quit(BOOL);
Logs you out of the IMAP server, expunges the selected mailbox, and closes the connection. No error message will ever be returned from this method β it simply does not do that. π
Optionally, if BOOL is TRUE (1) then a hard quit happens, which closes the socket connection. That hard quit still issues both the EXPUNGE and LOGOUT commands, but the response is ignored and the socket gets closed right after the commands go out.
logout
$imap->logout;
Just like quit, except it has no hard quit option and it does not expunge the mailbox before hanging up and closing the socket. π¦
last
my $message_number = $imap->last;
Returns the message number of the last message in the selected mailbox, since the last time that mailbox was selected. On failure nothing comes back and errstr() gets the error message.
delete
print "Gone!" if $imap->delete( $message_number );
Sets the \Deleted flag on the given message (or messages). True on success, false on failure (with errstr() set to the error message). If the flag was already there, no error β it's chill like that. Takes either a message number or a "sequence set" as its only argument.
β οΈ real talk: messages aren't actually deleted until they get expunged (see expunge_mailbox). the flag is just a vibe, not a funeral. πͺ¦
undelete
print "Resurrected!" if $imap->undelete( $message_number );
Removes the \Deleted flag on the given message. True on success, false on failure with errstr() set. If the flag wasn't there in the first place, no error is produced. it's giving resurrection arc β¨
see
print "You've seen message #$msgno" if $imap->see( $messageno );
Sets the \Seen flag on the given message. True on success, false on failure, and errstr() gets the error message. If the flag was already there, no error. π
unsee
print "You've not seen message #$msgno" if $imap->unsee( $messageno );
Removes the \Seen flag on the given message. True on success, false on failure, errstr() gets the error message. If the flag wasn't there, no error is produced. selective memory, we love her π
add_flags
Fun fact: delete and see above are really just calling this function for those flags.
$imap->add_flags( $msgno, qw(\Seen \Deleted) )
or die $imap->errstr;
sub_flags
And unsee above is really just calling this one for that flag.
$imap->sub_flags( $msgno, '\Seen' ) or die $imap->errstr;
mailboxes
my @boxes = $imap->mailboxes;
my @folders = $imap->mailboxes("Mail/%");
my @lists = $imap->mailboxes("lists/perl/*", "/Mail/");
Returns a list of mailboxes. Call it with no arguments and it recurses from the IMAP root to grab every mailbox. The first optional argument is a mailbox path, the second is the path reference. RFC 3501 section 6.3.8 has the full lore if you want it π.
On failure nothing comes back and errstr() is set with the error message.
mailboxes_subscribed
my @boxes = $imap->mailboxes_subscribed;
my @folders = $imap->mailboxes_subscribed("Mail/%");
my @lists = $imap->mailboxes_subscribed("lists/perl/*", "/Mail/");
Returns a list of mailboxes you're subscribed to π. No arguments = recurse from the IMAP root and get everything. First optional argument is a mailbox path, second is the path reference. RFC 3501 has more info.
On failure nothing is returned and the errstr() error handler gets set with the error message. π
π create_mailbox
print "Created" if $imap->create_mailbox( "/Mail/lists/perl/advocacy" );
Okay so this one literally creates the mailbox you name in the required argument. That's it, that's the whole vibe. β¨ Returns true on success, false on failure β and when it fails, the errstr() error handler is set with the error message. Bestie, always check your failures. π«Ά
π expunge_mailbox
my @expunged = $imap->expunge_mailbox( "/Mail/lists/perl/advocacy" );
die $imap->errstr if $imap->waserr;
my $expunged = $imap->expunge_mailbox( "/Mail/lists/perl/advocacy" )
or die $imap->errstr;
This method removes all the mail marked as deleted in the mailbox named in the required argument. Bye felicia πποΈ
So what does it return? Either the number of messages that were expunged, or the indexes of those messages β and ngl, that second one has questionable usefulness, because it tends to return numbers that don't actually relate to the message numbers marked with the \Deleted flags. It's giving chaos. π
If 0 messages were expunged without error, the function returns 0E0 so it will still test true, but also evaluate to 0. Iconic little Perl trick, fr fr.
β οΈ In list context you must call waserr() to test for success. No cap, don't skip this one.
πΈ delete_mailbox
print "Deleted" if $imap->delete_mailbox( "/Mail/lists/perl/advocacy" );
Deletes the mailbox named in the required argument. Returns true on success, false on failure, and the errstr() error handler is set with the error message. Simple, clean, mildly devastating. π
π¦ rename_mailbox
print "Renamed" if $imap->rename_mailbox( $old => $new );
Renames the mailbox in the first required argument to the mailbox named in the second required argument. Returns true on success, false on failure and the errstr() error handler is set with the error message. Two arguments, both required β don't be out here passing one and hoping for the best. π
β folder_subscribe
print "Subscribed" if $imap->folder_subscribe( "/Mail/lists/perl/advocacy" );
Subscribes to the folder. Returns true on success, false on failure and the errstr() error handler is set with the error message. Ring the bell, join the club π
π folder_unsubscribe
print "Unsubscribed" if $imap->folder_unsubscribe( "/Mail/lists/perl/advocacy" );
Un-subscribes to the folder. (Yes, that's the original phrasing β we keep the facts exactly as they are, even when the grammar is lowkey fighting for its life. π) Returns true on success, false on failure and the errstr() error handler is set with the error message. It's giving "I'm leaving the group chat" energy. πͺ
π§ copy
print "copied" if $imap->copy( $message_number, $mailbox );
Copies the message number (or sequence set) in the currently selected mailbox to the folder specified in the second argument. Both arguments are required β yes, both. On success this method returns true. Returns false on failure and the errstr() error handler is set with the error message. π
π uidcopy
print "copied" if $imap->uidcopy( $message_uid, $mailbox );
This method is identical to copy() above, except that it uses UID numbers instead of sequence numbers. Same energy, different number system. π₯
β noop
$imap->noop;
Performs a null operation. Sounds like it does nothing (because it kind of does!) but you might actually need it: it can get you updates on a mailbox, or ensure that the server doesn't close the connection as idle. π«Ά
RFC 3501 states that servers' idle timeouts must not be less than 30 minutes. So yeah, your connection has at minimum half an hour of chill. π
π errstr
print "Login ERROR: " . $imap->errstr . "\n" if !$imap->login($user, $pass);
Returns the last error string captured for the last operation which failed. Your receipts, basically. π§Ύβ¨
π©· waserr
my @flags = $imap->msg_flags(14);
die $imap->errstr if $imap->waserr;
Because msg_flags() can optionally return a list, it's not really possible to detect failure in list context. That's just how it is. π Therefore, you must call waserr() if you wish to detect errors. Periodt.
Few of the Net::IMAP::Simple methods use waserr(). The ones that do will mention it. So if a method's docs name-drop waserr(), that's your cue, bestie. π
π list2range
Sometimes you have a long list of sequence numbers which are consecutive and really want to be an IMAP-style range. This is that method. π
my @list = (5..9, 13..38, 55,56,57);
my $short = $imap->list2range(@list);
# $short how says: 5:9,13:38,55:57
Look at that glow-up. From a whole crowd to three tidy ranges. β¨
π¦ range2list
Pretty much the opposite of list2range. π
my @list = $imap->range2list("1,3,5:9");
# @list is (1,3,5,6,7,8,9);
Ranges in, list out. Math is mathing, we love to see it. π
β¨ SEARCHING β¨
π search
Okay bestie, so search is the main-character search function: it gives you an array of message numbers when you call it in list context, or the number of matched messages when you call it in scalar context. It takes exactly one argument: the search. π
IMAP searching can be a little confusing, and this function makes no attempt to parse your searches. If you wish to do searches by hand, please see <red>RFC 3501</red>. No cap, it's all on you.
IMAP sorting (see <red>RFC 5256</red>) is supported via an optional second argument. The RFC requires the charset be specified, and you can provide that via the optional third argument β it defaults to <mint>UTF-8</mint>. π¦
Here are a few examples, copied exactly because they are iconic:
my @ids = $imap->search("UNSEEN");
my @ids = $imap->search('SUBJECT "blarg is \"blarg\""');
my @ids = $imap->search('FROM "joe@aol.com"');
my @ids = $imap->search("DELETED");
# example from RFC 3501, search terms are ANDed together
my @ids = $imap->search('FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith"');
# example from RFC 3501, search terms are ORed together
my @ids = $imap->search('OR BODY "blard" SUBJECT "blarg"');
# flagged and ( since x or !from y ):
my @ids = $imap->search('FLAGGED OR SINCE x NOT FROM "y"');
# no typo above, see the RFC
# example from RFC 5256, sorted by subject and reverse date
my @ids = $imap->search('BODY "zaphod"', 'SUBJECT REVERSE DATE');
Since this module is meant to be simple, <purple>Net::IMAP::Simple</purple> has a few search helpers. If you need fancy booleans and things, you'll have to learn search. If you need a quick search for unseen messages, see below. π«Ά
These all return an array of messages or count of messages exactly as the search function does. Some of them take arguments, some do not. They do try to grok your arguments slightly, and the mechanics of this (if any) will be mentioned below. β¨
search_seen π
Returns numbers of messages that have the \Seen flag.
search_recent πΈ
Returns numbers of messages that have the \Recent flag.
search_answered π
Returns numbers of messages that have the \Answered flag.
search_deleted π
Returns numbers of messages that have the \Deleted flag.
search_flagged π₯
Returns numbers of messages that have the \Flagged flag.
search_draft π
Returns numbers of messages that have the \Draft flag.
search_unseen π
Returns numbers of messages that do not have the \Seen flag.
search_old π§
Returns numbers of messages that do not have the \Recent flag.
search_unanswered π
Returns numbers of messages that do not have the \Answered flag.
search_undeleted β
Returns numbers of messages that do not have the \Deleted flag.
search_unflagged π¦
Returns numbers of messages that do not have the \Flagged flag.
search_smaller π
This function takes a single argument we'll call <x> and returns numbers of messages that are smaller than <x> octets. This function will try to force your argument to be a number before passing it to the IMAP server. Literally doing the most. π«Ά
search_larger π
This function takes a single argument we'll call <x> and returns numbers of messages that are larger than <x> octets. This function will try to force your argument to be a number before passing it to the IMAP server. Periodt.
search_from π
This function takes a single argument we'll call <x> and returns numbers of messages that have <x> in the from header. This function will attempt to force your string into the <red>RFC3501</red> quoted-string format.
search_to π
This function takes a single argument we'll call <x> and returns numbers of messages that have <x> in the to header. This function will attempt to force your string into the <red>RFC3501</red> quoted-string format.
search_cc π
This function takes a single argument we'll call <x> and returns numbers of messages that have <x> in the cc header. This function will attempt to force your string into the <red>RFC3501</red> quoted-string format.
search_bcc π
This function takes a single argument we'll call <x> and returns numbers of messages that have <x> in the bcc header. This function will attempt to force your string into the <red>RFC3501</red> quoted-string format.
search_subject π
This function takes a single argument we'll call <x> and returns numbers of messages that have <x> in the subject header. This function will attempt to force your string into the <red>RFC3501</red> quoted-string format.
search_body π
This function takes a single argument we'll call <x> and returns numbers of messages that have <x> in the message body. This function will attempt to force your string into the <red>RFC3501</red> quoted-string format.
search_before β°
This function takes a single argument we'll call <x> and returns numbers of messages that were received before <x>. If you have <blue>Date::Manip</blue> installed (optional), this function will attempt to force the date into the format "%d-%b-%Y" (date-monthName-year) as <red>RFC3501</red> requires. If you do not have that module, no attempt will be made to coerce your date into the correct format. π
search_since β°
This function takes a single argument we'll call <x> and returns numbers of messages that were received after <x>. If you have <blue>Date::Manip</blue> installed (optional), this function will attempt to force the date into the format "%d-%m-%Y" (date-month-year) as <red>RFC3501</red> requires. If you do not have that module, no attempt will be made to coerce your date into the correct format. π
search_sent_before β°
This function takes a single argument we'll call <x> and returns numbers of messages that have a header date before <x>. If you have <blue>Date::Manip</blue> installed (optional), this function will attempt to force the date into the format "%d-%m-%Y" (date-month-year) as <red>RFC3501</red> requires. If you do not have that module, no attempt will be made to coerce your date into the correct format. π
search_sent_since β°
This function takes a single argument we'll call <x> and returns numbers of messages that have a header date after <x>. If you have <blue>Date::Manip</blue> installed (optional), this function will attempt to force the date into the format "%d-%m-%Y" (date-month-year) as <red>RFC3501</red> requires. If you do not have that module, no attempt will be made to coerce your date into the correct format. π
π uidsearch
This function works exactly like search() but it returns UIDs instead of sequence numbers. The convenient shortcuts above are not provided for it. That's the whole vibe. π
π OTHER NOTES π
π sequence set
Message numbers are never checked before being passed to the IMAP server (this is a "simple" module after all), so in most places where a message number is required, you can instead use so-called sequence sets. Examples, exactly:
$imap->copy( "3,4,9:22", "ANOTHERBOX" ) or die $imap->errstr;
$imap->delete( "3,4,9:22" ) or die $imap->errstr;
π AUTHOR π
Creator
Joao Fonseca "<joao_g_fonseca@yahoo.com>"
Maintainer 2004
Casey West "<casey@geeknst.com>"
Maintainer 2005
Colin Faber "<cfaber@fpsn.net>"
Maintainer 2009
Paul Miller "<jettero@cpan.org>"
π COPYRIGHT π
Copyright (c) 2009-2010 Paul Miller Copyright (c) 2005 Colin Faber Copyright (c) 2004 Casey West Copyright (c) 1999 Joao Fonseca
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π
π LICENSE π
This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0. β¨
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
[This software may have had previous licenses, of which the current maintainer is completely unaware. If this is so, it is possible the above license is incorrect or invalid.]
π BUGS π
There are probably bugs. But don't worry, the current maintainer takes them very seriously and will usually triage (at least) within a single day. π
<https://rt.cpan.org/Dist/Display.html?Queue=Net-IMAP-Simple>
π SEE ALSO π
perlNet::IMAP::ServerIO::Socket::SSLIO::Socket::INET6
That's the whole page, bestie β it came from perl v5.26.2, dated 2018-05-21, and that's the cute little footer energy we're ending on. πβ¨π
π¦ where this page comes from
- debian bookworm: libnet-imap-simple-perl 1.2211-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-imap-simple-perl 1.2211-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libnet-imap-simple-perl 1.2211-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-imap-simple-perl 1.2211-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms