Postfi...::Mailq(3pm)
β¨ NAME β¨
Postfix::Parse::Mailq β bestie, this is the module that parses the output of the postfix mailq command π
Like, you run mailq, you get a wall of text, and this lil icon turns that wall into actual data you can loop over. Periodt.
πΈ VERSION πΈ
version 1.005 β she's vintage, she's cozy π
π¦ SYNOPSIS π¦
okay so here's the vibe:
use Postfix::Parse::Mailq;
my $mailq_output = `mailq`;
my $entries = Postfix::Parse::Mailq->read_string($mailq_output);
my $bytes = 0;
for my $entry (@$entries) {
next unless grep { /\@aol.com$/ } @{ $entry->{remaining_rcpts} };
$bytes += $entry->{size};
}
print "$bytes bytes remain to send to AOL destinations\n";
the way that it grabs the raw mailq output, parses it, then just... sums up bytes for every entry still waiting on an AOL destination? obsessed π
π METHODS π
read_file
read_handle
read_string
my $entries = Postfix::Parse::Mailq->read_string($string, \%arg);
these three read the output of postfix's mailq from a file (by name), a filehandle, or a string, respectively β pick your flavor sis π
they hand back an arrayref of hashrefs, and each hashref is one entry in the queue, exactly as reported by mailq.
here's what you're allowed to pass in as arguments:
spoolβ a hashref of{ queue_id -> spool_name }pairs. if you give it, it gets used to try and indicate which spool the messages are currently sitting in. it is not entirely reliable (race!), so don't treat it like gospel bestie π
parse_block
my $entry = Mailq->parse_block(\@lines);
hand it all the lines that make up a single entry's block within the mailq output, and it gives you back the data for that entry. one block in, one entry of info out β¨
π WARNING π
This code is really rough and the interface will change. Entries will be objects. There will be some more methods. Still, the basics are likely to keep working, or keep pretty close to what you see here now.
fr fr, she's a work in progress. entries are gonna become objects, more methods are coming, the interface is gonna shift. but the basics? probably gonna keep working, or at least stay pretty close to what you're reading right here. so don't panic, just don't get too attached to the fine details π
π AUTHOR π
Ricardo SIGNES <rjbs@cpan.org>
π«Ά CONTRIBUTOR π«Ά
Johan Carlquist <jocar@su.se>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2015 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page bestie, no cap π this was Postfi...::Mailq for perl v5.36.0, dated 2022-10-14 β and yes, 1.005 is the version, we said it twice, she's worth it. go parse some queues, you got this βπ§
π¦ where this page comes from
- ubuntu noble: libpostfix-parse-mailq-perl 1.005-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpostfix-parse-mailq-perl 1.005-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpostfix-parse-mailq-perl 1.005-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