Test::POP3(3pm)
π Test::POP3 β the perl doc you're literally about to read
okay bestie, so this is Test::POP3(3pm), from the User Contributed Perl Documentation crew π«Ά β it's the module that lets you automate email delivery tests, and honestly? it ate. Let's get into it π
β¨ NAME β¨
Test::POP3 β Automate Email Delivery Tests π
πΈ SYNOPSIS πΈ
use Test::POP3;
my $pop = Test::POP3->new({
host => $host,
user => $user,
pass => $pass,
});
# this will delete all messages from the server
ok($count == $pop->wait_for_email_count($count,$timeout),"got $count");
# find and delete a single email message which matches these rules
# see Test::Email for more information
$pop->ok({
# optional search parameters
to => ($is or qr/is like/),
from => ($is or qr/is like/),
subject => ($is or qr/is like/),
body => ($is or qr/is like/),
headername => ($is or qr/is like/),
}, "got message");
ok($pop->get_email_count() == $count, "$count emails in cache");
# get the Test::Email object
my @email = $pop->get_email();
ok($pop->delete_all() == 2, "deleted 2 messages");
# tweak MIME::Parser settings
my $parser = $pop->get_parser();
π¦ DESCRIPTION π¦
π¨ PLS READ π¨ this is ALPHA CODE. like, alpha. so the interface is lowkey likely to change, no cap. don't come for me when it shifts. π
This module helps you build automated tests for email that gets delivered to a POP3 account. it's giving "set it and forget it" but for inboxes π
Messages you pull from the server but that haven't been matched by a test yet get cached β they sit there until either (a) that message is the first one to pass a test, or (b) it gets returned by $pop3->get_email(). And the messages that come back? They're Test::Email objects, periodt. β¨
π METHODS π
my $pop = Test::POP3->new($href);The arguments you pass in the href arehost,user, andpass. that's the whole vibe check π«Άmy $count = $pop->wait_for_email_count($count, $timeout_seconds?);Calling this method will result in all messages being deleted from the server. π³ (yes, fr fr.) It'll wait up to$timeoutseconds for there to be$countunprocessed messages found on the server. Once$countor more messages show up β or once$timeoutseconds have passed β the current email count gets returned. And$timeout_secondsdefaults to30β±οΈmy @email = $pop->get_email();Grab all the email messages currently chilling in the local cache. If you think there might still be messages on the server waiting to be retrieved, you should call$pop3->wait_for_email_count($count)before this method. Heads up: calling this method causes the local cache to be emptied π. The email messages you get back areTest::Emailobjects.my $count = $pop->get_email_count($check_server);Returns the number of email messages in the cache. If$check_serveris true, the server gets checked once before the count is determined. And if you wanna wait for messages to arrive on the server and then get downloaded before counting? Use$pop3->wait_for_email_count()instead πmy $ok = $pop->ok($test_href, $description);Calling this method tests the email in the local cache according to whatever's inside$test_href. The first email that passes all the tests gets deleted from the local cache. Since this method only checks the local cache, you're gonna wanna call$pop3->wait_for_email_count()before it. Andokproduces TAP output β identical toTest::Simple::okandTest::More::okβmy $parser = $pop->get_parser();Test::POP3usesMIME::Parserto process the messages. (MIME is not yet handled byTest::Emailβ it will be soon, bestie, stay tuned π.) Use this method if you want to manage the parser yourself.
π EXPORT π
None.
like... nothing. zero. empty. the void. π
π SEE ALSO π
Test::Builder, Test::Simple, Test::More, MIME::Parser
go read those too, iykyk π
π AUTHOR π
James Tolley, <james@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2007 by James Tolley
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
and that's the whole page, babe π₯° this was perl v5.34.0, dated 2022-06-17, and it's still Test::POP3(3pm) β slay, go write some tests, you got this ππβ¨
π¦ where this page comes from
- debian bookworm: libtest-email-perl 0.07-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-email-perl 0.07-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-email-perl 0.07-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-email-perl 0.07-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-email-perl 0.07-3 Β· 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