Mail::...t::POP3(3pm)
π Mail::Transport::POP3 π
from the 3pm section, a.k.a. User Contributed Perl Documentation β hi bestie, come get your mail π«Ά
π NAME π
Mail::Transport::POP3 β receive messages via POP3, no cap β¨
π¦ INHERITANCE π¦
so the family tree is giving:
Mail::Transport::POP3- is a
Mail::Transport::Receive - is a
Mail::Transport - is a
Mail::Reporter
- is a
it's the nepo baby of a very respectable Perl dynasty π
π SYNOPSIS π
the whole vibe, in two lines:
my $receiver = Mail::Transport::POP3->new(...);
my $message = $receiver->receive($id);
that's it. that's the plot π
β¨ DESCRIPTION β¨
okay so picture this: you're pulling messages off one remote server over the POP3 protocol, exactly like rfc1939 describes. this object exists so you don't have to touch the messy parts of the protocol with your bare hands β and lowkey it heals broken connections all by itself, which is iconic behavior honestly. and even though it ships inside the MailBox distribution, you can absolutely use it on its own, it does not need the groupchat.
π«Ά real talk though: you probably shouldn't use this module directly. useMail::Box::POP3instead. this module is the raw interface to POP3, meanwhileMail::Box::POP3handles all the protocol weirdness and acts like literally any other mail folder. so much easier on your nervous system.
also it extends "DESCRIPTION" in Mail::Transport::Receive, so anything happening there is happening here too.
π METHODS π
extends "METHODS" in Mail::Transport::Receive β so we're building on top of all that πΈ
π οΈ Constructors π οΈ
extends "Constructors" in Mail::Transport::Receive.
$class->new(%options)
creates a brand new pop3 server connection. and listen β one object handles exactly one connection: one single user, one single server, that's the whole arrangement, we don't share π«
if the server couldn't be reached, or the login fails? new just returns undef. no drama, just nothing. it improves on the base, so check "Constructors" in Mail::Reporter for the full lore.
here's the option menu, with defaults, fresh off the counter:
authenticateβ default'AUTO'executableβ fromMail::Transport, defaultundefhostnameβ fromMail::Transport, default'localhost'intervalβ fromMail::Transport, default30passwordβ fromMail::Transport, defaultundefportβ fromMail::Transport, default110proxyβ fromMail::Transport, defaultundefretryβ fromMail::Transport, default<unlimited>ssl_optionsβ defaultundeftimeoutβ fromMail::Transport, default120use_sslβ defaultfalseusernameβ fromMail::Transport, defaultundefviaβ fromMail::Transport, default'sendmail'
now the ones that come with commentary:
- **
authenticate=>'LOGIN'|'APOP'|'AUTO'|OAUTH2'|'OAUTH2_SEP'** β the authentication method, bestie. the standard defines two of them, and they're called LOGIN and APOP. LOGIN straight-up sends your username and password to the server in plain text to get permission (π yes really), whereas APOP encrypts that data using MD5, which is the responsible choice. whenAUTO` is set, it tries APOP first, and then falls back to LOGIN.
the OAUTH* ones need the authorization token passed as Password. also β Microsoft Office365 specifically needs OAUTH2_SEP, while other oauth2 implementations use just OAUTH2. iykyk π
executable=>$fileβ yeah. see the parent class for the deets.hostname=>$host|\@hostsβ plural hosts is allowed, she contains multitudes.interval=>$spanβ the timing situation.password=>$passwordβ your secret. guard it.port=>$portβ the door number.proxy=>$pathβ the go-between.retry=>$count|undefβ how many times we're willing to try again.ssl_options=>HASHβ unless you overrule it,verify_hostnamewill be set tofalseandSSL_verify_modetoSSL_VERIFY_NONE}. yes that's how it's written, we don't touch the source β
you can also set the SSL parameters via the IO::Socket::SSL subroutine set_defaults. heads up though: connections get restarted whenever they're lost, so you have to keep those defaults in place the entire time you're doing POP actions, or it all falls apart.
timeout=>$spanβ how long before we give up waiting.use_ssl=>BOOLEANβ on or off, babes.username=>$usernameβ who you are.via=>CLASS|$nameβ the route it takes.
π Attributes π
extends "Attributes" in Mail::Transport::Receive.
$obj->SSLOptions()β the SSL options, as requested β¨$obj->supportsUIDL()β does the server supportUIDL? this tells you. lowkey important, remember this one π$obj->useSSL()β returns"true"when SSL must be used. periodt.
π¬ Receiving mail π¬
extends "Receiving mail" in Mail::Transport::Receive.
$obj->receive( [$unique_message_id] )β inherited, so go read "Receiving mail" inMail::Transport::Receivefor the full story π«Ά
π Exchanging information π
$obj->deleteFetched()β marks every message that got fetched viamessage()for deletion. seefetched(). bye babes π$obj->deleted(BOOLEAN, @ids)β either flags the specified message(s) to be deleted on the remote server, or unflags them (if the first parameter is"false"). and here's the spicy part: the deletion doesn't actually happen until you specifically disconnect, or until the very last reference to the object goes out of scope. so don't be surprised when they're still there π$obj->disconnect()β breaks contact with the server, if that contact (still) exists. returns"true"if successful. and yes β even if the disconnect was NOT successful, all your knowledge of messages and everything else gets wiped from the object anyway. the object has basically reverted to the state it was in before you did anything at all with the mail box. it's giving memory loss, honestly π$obj->fetched()β returns a reference to a list of ID's that have been fetched usingmessage(). you can use this to update a database of messages that were fetched (but maybe not yet deleted) from the mailbox.
but listen: if the POP3 server didn't support the UIDL command, this method will always return "undef", because it's simply not possible to reliably identify messages between sessions β other than by looking at the contents of the messages themselves. so yeah π₯²
see also deleteFetched().
$obj->folderSize()β returns the total number of octets used by the mailbox on the remote server. big folder energy π₯$obj->header( $id, [$bodylines] )β returns an ARRAY containing the header of the message with the specified$id. aundefcomes back if something has gone wrong.
the optional integer $bodylines says how many lines from the body should be added β by default, none.
example:
my $ref_lines = $pop3->header($uidl);
print @$ref_lines;
$obj->id2n($id)β translates the unique$idof a message into a sequence number, which represents the message for as long as this connection to the POP3 server exists. if the message has been deleted for some reason,undefcomes back instead.$obj->ids()β returns all IDs the server knows about right now. in list context you get a list, in scalar context you get a reference to a list. flexible queen π$obj->message($id)β returns a reference to an array containing the lines of the message with the specified$id. returnsundefif something has gone wrong.
example:
my $ref_lines = $pop3->message($uidl);
print @$ref_lines;
$obj->messageSize($id)β returns the size of the message indicated by$id, measured in octets. if that message has been deleted on the remote server, this returnsundef. gone girl π¦$obj->messages()β returns (scalar context only!!) the number of messages known to exist in the mailbox.
π§ Protocol internals π§
these next methods handle protocol internals, and a normal user of this class should not be touching them. respectfully, hands off π
$obj->login()β establishes a new connection to the POP3 server, using username and password.$obj->send($socket, $data)β sends$datato the indicated socket and returns the first line read back from that socket. logs an error if writing to or reading from the socket failed.
this method does not attempt to reconnect or anything like that: if reading or writing the socket fails, something is very definitely wrong. like, very. π¨
$obj->sendList($socket, $command)β sends the indicated$commandto the specified socket, and retrieves the response. it returns a reference to an array holding all the lines that were received after the first"+OK"line and before the end-of-message delimiter (which is a single dot on a line). returnsundefwhenever something has gone wrong.$obj->socket()β returns a connection to the POP3 server. if there was no connection yet, one gets created transparently. if the connection with the POP3 server was lost, it will be reconnected, and it makes sure the internal state information (STAT and UIDL) is up-to-date in the object. it's got main character energy, it heals itself π
if the contact to the server was still present, or could be established, an IO::Socket::INET object is returned. otherwise, undef is returned, and you should not try any further actions on the object. that's a wrap, bestie π
$obj->status($socket)β updates the current status of the folder on the remote POP3 server.
π Server connection π
extends "Server connection" in Mail::Transport::Receive.
$obj->findBinary( $name, [@directories] )β inherited, see "Server connection" inMail::Transport.$obj->remoteHost()β inherited, see "Server connection" inMail::Transport.$obj->retry()β inherited, see "Server connection" inMail::Transport.$obj->url()β represents this pop3 connection as a URL. cute β¨
π Error handling π
extends "Error handling" in Mail::Transport::Receive.
$obj->AUTOLOAD()β inherited, see "Error handling" inMail::Reporter.$obj->notImplemented()β inherited, see "Error handling" inMail::Reporter.
π§Ή Cleanup π§Ή
extends "Cleanup" in Mail::Transport::Receive.
$obj->DESTROY()β inherited, see "Cleanup" inMail::Reporter. it cleans up after itself, we love a tidy queen πΈ
π DIAGNOSTICS π
Okay so when things go sideways, this module throws exception objects, and every single one of them is listed below with what it means and who threw it. Read 'em like the receipts they are, bestie. π§Ύ
Error: POP3 Could not do a STAT
For some weird reason, the server just... does not respond to the STAT call. Rude of it. Cast by status().
Error: POP3 requires a username and password.
You didn't give a username, you didn't give a password, or you gave neither β for this POP3 folder. But those two things are obligatory parts of the protocol, so like, we can't work with nothing. Cast by login().
Fault: cannot connect to $service for POP3: $!
Couldn't connect to the remote POP3 server, periodt. Cast by login().
Error: cannot get all messages of pop3 at once via messages().
Retrieving every message on a remote POP3 folder all at once? Not possible, bestie β each one has to be taken separately. (The POP3 folder hides this whole situation from you, don't worry. π
) Cast by messages().
Error: cannot re-connect reliably to server which doesn't support UIDL.
The connection to the remote POP3 dropped, and it cannot be re-established, because the server's protocol implementation is missing the information needed to do it. Cast by socket().
Fault: cannot read POP3 from socket: $!
Couldn't read the success status of the POP3 command you sent before. Connection lost, maybe? π Cast by send().
Error: cannot write POP3 to socket: $@
Couldn't send a protocol command to the POP3 server. Also possibly a lost connection? π Cast by send().
Error: class $package does not implement method $method.
Fatal: that specific $package (or one of its superclasses) does not implement this method, even though it should. What this message actually means is that some other related classes do implement the method, but the class you're holding does not. So probably go investigate, and probably tell the author of the package. Cast by notImplemented().
Error: could not authenticate using '$type' method.
That authentication method did not get you access to the POP3 server. Maybe you need a different authentication protocol, or maybe your username + password are just invalid. Cast by login().
Error: could not authenticate using any login method.
No authentication method was explicitly prescribed, so both AUTH and APOP got tried β and both failed. π There are other authentication methods out there that the main POP3 RFC, rfc1939, doesn't define. Those protocols are not implemented yet. So if you're feeling generous, please contribute your implementation. Cast by login().
Error: server at $service does not seem to be talking POP3.
The remote server didn't respond to the initial exchange of messages the way the POP3 protocol expects. Probably there's a completely different service sitting on that port. π Cast by login().
π SEE ALSO π
This module is part of Mail-Box-POP3 version 4.02, built on April 10, 2026. Website: http://perl.overmeer.net/CPAN/ β¨
π LICENSE π
Contributors, go look at the file ChangeLog.
This software is copyright (c) 2001-2026 by Mark Overmeer. π
It's free software β you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay, honestly. π
And that's the whole page, bestie β written against perl v5.40.1 and dated 2026-05-09, courtesy of the user-contributed Perl documentation. Go forth and POP3 responsibly. π«Άπ
π¦ where this page comes from
- ubuntu stonking: libmail-box-pop3-perl 4.02-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms