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

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. use Mail::Box::POP3 instead. this module is the raw interface to POP3, meanwhile Mail::Box::POP3 handles 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 β€” from Mail::Transport, default undef
  • hostname β€” from Mail::Transport, default 'localhost'
  • interval β€” from Mail::Transport, default 30
  • password β€” from Mail::Transport, default undef
  • port β€” from Mail::Transport, default 110
  • proxy β€” from Mail::Transport, default undef
  • retry β€” from Mail::Transport, default <unlimited>
  • ssl_options β€” default undef
  • timeout β€” from Mail::Transport, default 120
  • use_ssl β€” default false
  • username β€” from Mail::Transport, default undef
  • via β€” from Mail::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. when AUTO` 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_hostname will be set to false and SSL_verify_mode to SSL_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 support UIDL? 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" in Mail::Transport::Receive for the full story 🫢

πŸ”„ Exchanging information πŸ”„

  • $obj->deleteFetched() β€” marks every message that got fetched via message() for deletion. see fetched(). 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 using message(). 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. a undef comes 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 $id of 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, undef comes 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. returns undef if 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 returns undef. 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 $data to 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 $command to 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). returns undef whenever 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" in Mail::Transport.
  • $obj->remoteHost() β€” inherited, see "Server connection" in Mail::Transport.
  • $obj->retry() β€” inherited, see "Server connection" in Mail::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" in Mail::Reporter.
  • $obj->notImplemented() β€” inherited, see "Error handling" in Mail::Reporter.

🧹 Cleanup 🧹

extends "Cleanup" in Mail::Transport::Receive.

  • $obj->DESTROY() β€” inherited, see "Cleanup" in Mail::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