Test::M...onUtils(3)

πŸ“¦ version 3.20, in alpine 3.24

🌸 NAME 🌸

Test::Mailmunge::RegressionUtils β€” utility functions for Mailmunge regression tests, bestie.

This is the Test::M...onUtils(3) page from the User Contributed Perl Documentation, if you were wondering. πŸ’…

✨ ABSTRACT ✨

Okay so this class defines a number of functions in the main package that are useful for regression tests. That’s it, that’s the abstract, periodt. πŸ’–

πŸ’€ GIANT WARNING πŸ’€

Bestie, buckle up, because this is the giant warning:

The mailmunge regression-tests assume they are running in an environment similar to the docker images built by the build-docker-container supplied in the mailmunge source code. THEY ARE UNLIKELY TO WORK IN ANY OTHER ENVIRONMENT.

No cap, that’s a whole vibe check β€” do not expect them to work anywhere else. 😭


🧚 FUNCTIONS 🧚

slurp_body_only ($file) 🌸

$file is assumed to be an RFC5322 mail message. Return only the body of the message after skipping the header lines. Slay, headers begone. ✨

server_running_postfix() πŸ’Œ

Returns true if it looks like the regression-test server is running Postfix; false otherwise. We assume the server is running Sendmail if it’s not running Postfix. Lowkey important to know which MTA is in its main character era. πŸ‘‘

get_smtp_server_ip() πŸ¦‹

Returns the regression-test server’s IP address if it could be determined; undef if not. This will not be the loopback address, but the IP address of a non-loopback interface. Fr fr, it’s the real-network IP. 🌈

smtp_send($ip, $helo, $sender, $recips, $msg) πŸ’Œ

Runs an SMTP session. Connects to $ip and HELOs as $helo. Use $sender as the envelope sender. Uses each recipient in @$recips in a RCPT To: command. ($recips must be an arrayref.) And transmits $msg as the message body; $msg must be a string representing an RFC5322 mail message.

Returns a hash containing:

  • stage β€” The stage at which the SMTP session ended. One of "connect", "helo", "mail", "rcpt", "data", "datasend", or "quit".
  • code β€” The three-digit SMTP code returned by the SMTP server for the final command sent.
  • dsn β€” The three-number "a.b.c" DSN returned by the SMTP server for the final command sent.
  • txt β€” The reply text returned by the SMTP server for the final command sent.

It’s giving full receipts from the SMTP convo. πŸ’…

maildrop_msg_dir() πŸ“¬

Returns the directory in which regression-test messages are dropped. That’s the maildrop inbox vibe. πŸŽ€

clean_maildrop_dir() 🧹

Deletes all files in maildrop_msg_dir(). Cleanup era, absolutely iconic. ✨

maildrop_msg_path([$file]) πŸ“

Returns the full path to the maildrop file. If $file is not supplied, defaults to 'maildrop.msg'. Default behavior ate, no cap. πŸ’–

quarantine_dir() πŸ¦‹

Returns the quarantine directory '/var/spool/mm-quarantine'. Yes, that exact path, bestie. 🌸

clean_quarantine_dir() 🧼

Deletes all files from the quarantine directory. Bye-bye, quarantined little guys. πŸ‘‹

first_quarantined_msg() πŸ”₯

Returns the first directory under quarantine_dir() that has a quarantined message. Returns undef if no quarantined messages are found. It’s giving β€œfirst one to show up gets the spotlight.” πŸ‘‘

make_msg($subject, $source_msg, $output_file) πŸ’Œ

Returns a string containing an RFC5322 message taken from the file "t/msgs/$source_msg". The string "__SUBJECT__" in that file is replaced with $subject. If $output_file is provided, then the string ": maildrop.msg" in the source message is replaced with ": $output_file". This directs the regression-test maildrop process to drop the message in "maildrop_msg_dir() . '/' . $output_file". Literally customizing the message drop path, periodt. πŸŽ€

wait_for_files($file1 [, $file2 ...]) ⏳

Waits up to (about) four seconds for all files named in the argument list to exist. Returns 1 if all of the files exist, or 0 if the function timed out before all files appeared. Four seconds of hopeful staring, basically. 😭

flush_mta_queues() πŸ”₯

Flushes the MTA queues using the appropriate commands depending on whether the MTA is Sendmail or Postfix. You need to run the regression tests as root for this to work. Root energy required, bestie. πŸ‘‘

clean_mta_queues() 🧹

Clears out the MTA queues using the appropriate commands depending on whether the MTA is Sendmail or Postfix. Again, only works if you’re running as root. Same root requirement, same slay. πŸ’…

get_mta_hold_queue() πŸ“¦

Returns an arrayref of queue-IDs in the MTA’s "hold" queue. The contents of the arrayref are unspecified, but the number of items is the number of messages in the "hold" queue of the MTA. So like, don’t count on the contents, but do count them. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Dianne Skoll <dianne@skollsoft.com> β€” iconic author moment. πŸ’–

πŸŽ€ LICENSE πŸŽ€

This code is licensed under the terms of the GNU General Public License, version 2. 🌈


Later, bestie! πŸ’‹ This was Test::M...onUtils(3), from perl v5.42.2, dated 2025-10-05. Mwah! βœ¨πŸ’…

πŸ“¦ where this page comes from