Postfi...::Mailq(3pm)

πŸ“¦
version 1.005 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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>


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