1Test::POP3(3)         User Contributed Perl Documentation        Test::POP3(3)
2
3
4

NAME

6       Test::POP3 - Automate Email Delivery Tests
7

SYNOPSIS

9         use Test::POP3;
10
11         my $pop = Test::POP3->new({
12             host => $host,
13             user => $user,
14             pass => $pass,
15         });
16
17         # this will delete all messages from the server
18         ok($count == $pop->wait_for_email_count($count,$timeout),"got $count");
19
20         # find and delete a single email message which matches these rules
21         # see Test::Email for more information
22         $pop->ok({
23           # optional search parameters
24           to         => ($is or qr/is like/),
25           from       => ($is or qr/is like/),
26           subject    => ($is or qr/is like/),
27           body       => ($is or qr/is like/),
28           headername => ($is or qr/is like/),
29         }, "got message");
30
31         ok($pop->get_email_count() == $count, "$count emails in cache");
32
33         # get the Test::Email object
34         my @email = $pop->get_email();
35
36         ok($pop->delete_all() == 2, "deleted 2 messages");
37
38         # tweak MIME::Parser settings
39         my $parser = $pop->get_parser();
40

DESCRIPTION

42       Please note that this is ALPHA CODE. As such, the interface is likely
43       to change.
44
45       This module can help you to create automated tests of email delivered
46       to a POP3 account.
47
48       Messages retrieved from the server but not yet matched by a test will
49       be cached until either that message is the first to pass a test, or is
50       returned by "$pop3->get_email()". Messages returned are Test::Email
51       objects.
52

METHODS

54       "my $pop = Test::POP3->new($href);"
55           The arguments passed in the href are host, user, and pass.
56
57       "my $count = $pop->wait_for_email_count($count, $timeout_seconds?);"
58           Calling this method will result in all messages being deleted from
59           the server.  This will wait up to $timeout seconds for there to be
60           $count unprocessed messages found on the server. After $count or
61           more messages are found, or after $timeout seconds, the current
62           email count will be returned. $timeout_seconds defaults to 30.
63
64       "my @email = $pop->get_email();"
65           Get all of the email messages currently in local cache. You should
66           call "$pop3->wait_for_email_count($count)" before calling this
67           method if you think that there may be messages on the server yet to
68           be retrieved.  Calling this method will cause the local cache to be
69           emptied. Email messages returned will be Test::Email objects.
70
71       "my $count = $pop->get_email_count($check_server);"
72           This will return the number of email messages in the cache. If
73           $check_server is true, then the server will be checked once before
74           the count is determined.  If you would like to wait for messages to
75           arrive on the server, and then be downloaded prior to counting, use
76           "$pop3->wait_for_email_count()".
77
78       "my $ok = $pop->ok($test_href, $description);"
79           Calling this method will cause the email in the local cache to be
80           tested, according to the contents of $test_href. The first email
81           which passes all tests will be deleted from the local cache. Since
82           this method only checks the local cache, you will want to call
83           "$pop3->wait_for_email_count()" before calling this method. "ok"
84           will produce TAP output, identical to "Test::Simple::ok" and
85           "Test::More::ok".
86
87       "my $parser = $pop->get_parser();"
88           Test::POP3 uses MIME::Parser to process the messages. (MIME is not
89           yet handled by "Test::Email", it will be soon.) Use this method if
90           you want to manage the parser.
91

EXPORT

93       None.
94

SEE ALSO

96       Test::Builder, Test::Simple, Test::More, MIME::Parser
97

AUTHOR

99       James Tolley, <james@cpan.org>
100
102       Copyright (C) 2007 by James Tolley
103
104       This library is free software; you can redistribute it and/or modify it
105       under the same terms as Perl itself, either Perl version 5.8.8 or, at
106       your option, any later version of Perl 5 you may have available.
107
108
109
110perl v5.30.0                      2019-07-26                     Test::POP3(3)
Impressum