Mail::MIMEDefang(3)
π Mail::MIMEDefang π
okay bestie, sit down, hydrate, because we're talking about Mail::MIMEDefang β the email filtering milter. yep, that's the whole name, no notes. this is the Mail::MIMEDefang(3) manual page and i'm about to make it make sense, fr fr. π¦
β¨ NAME β¨
Mail::MIMEDefang β email filtering milter. that's it. that's the name. iconic. π
πΈ DESCRIPTION πΈ
Mail::MIMEDefang is a whole framework for filtering e-mail. the way it works: it uses Sendmail's "Milter" API, plus some C glue code, plus some Perl code, and together they let you write high-performance mail filters in Perl. no cap. π₯
so like, why do people even use MIMEDefang? bestie, let me list:
- Block viruses π¦
- Block or tag spam
- Remove HTML mail parts
- Add boilerplate disclaimers to outgoing mail
- Remove or alter attachments
- Replace attachments with URL's
- Implement sophisticated access controls.
and honestly? you're limited only by your imagination. if you can think of it and code it in Perl, you can do it with MIMEDefang. periodt. π
π METHODS π
init_globals
Initialize global variables used across MIMEDefang instance and filter. housekeeping first, always. π§Ή
print_and_flush(text)
Prints to stdout and flush buffer. say it out loud and don't hold it in. π£οΈ
md_openlog(tag, facility)
Initialize e syslog object using Sys::Syslog or Unix::Syslog as appropriate. whichever one fits, it picks. β¨
md_syslog(facility, msg)
Prints a message to syslog(3) using the specified facility.
md_graphdefang_log
This is called to log events that occur during mimedefang processing. It should be called from mimedefang-filter with appropriate event names and values.
Possible examples:
md_graphdefang_log('virus',$VirusName,$filename);
md_graphdefang_log('spam',$hits);
md_graphdefang_log('bad_filename',$filename,$extension);
If you need to log UTF-8 strings you can call the sub as:
md_graphdefang_log('spam',$hits, undef, 1);
md_graphdefang_log_array
This is called to log events that occur during mimedefang processing. It should be called from mimedefang-filter with appropriate event names and values.
Possible examples:
md_graphdefang_log_array('virus',0,\@info);
If you need to log UTF-8 strings you can call the sub as:
md_graphdefang_log_array('spam',1,\@info);
detect_and_load_perl_modules
Automatically detect and load Perl modules needed for some features like SpamAssassin, rbl checks, zip file listing and HTML parsing. it does the homework for you, love that. π
detect_antivirus_support
Check if antivirus support should be loaded by looking at %Features.
init_status_tag
Open the status file descriptor.
set_status_tag(depth, tag)
Sets the status tag for this worker inside the multiplexor.
push_status_tag(tag)
Updates status tag inside multiplexor and pushes onto stack.
pop_status_tag
Pops previous status of stack and sets tag in multiplexor.
percent_encode(str)
Encode a string with unsafe chars as "%XY" where X and Y are hex digits.
percent_encode_for_graphdefang(str)
Encode a string with unsafe chars as "%XY" where X and Y are hex digits.
Quotes or spaces are not encoded but commas are encoded. yes, it's picky like that. π
percent_decode(str)
Decode a string previously encoded by percent_encode().
write_result_line ( $cmd, @args )
Writes a result line to the RESULTS file.
$cmd should be a one-letter command for the RESULTS file.
@args are the arguments for $cmd, if any. They will be percent_encode()'ed before being written to the file.
Returns 0 or 1 and an optional warning message.
signal_unchanged
Tells mimedefang C program message has not been altered. untouched, unbothered. β
signal_changed
Tells mimedefang C program message has been altered. glow up confirmed. π«
in_message_context(name)
Returns 1 if we are processing a message; 0 otherwise.
in_filter_wrapup(name)
Returns 1 if we are not in filter wrapup; 0 otherwise.
in_filter_context
Returns 1 if we are inside filter or filter_multipart, 0 otherwise.
in_filter_end(name)
Returns 1 if we are inside filter_end 0 otherwise.
send_quarantine_notifications
Sends quarantine notification message, if anything was quarantined. snitches get... notifications. π¬
signal_complete
Tells mimedefang C program Perl filter has finished successfully.
Also mails any quarantine notifications and sender notifications.
send_mail(fromAddr, fromFull, recipient, body, deliverymode)
Sends a mail message using Sendmail.
Invokes Sendmail without involving the shell, so that shell metacharacters won't cause security problems. very demure, very safe. π«Ά
Delivery mode parameter is the optional sendmail delivery mode arg (default "-odd").
send_multipart_mail(fromAddr, fromName, recipient, subject, body_text, body_html, extra_headers)
Sends a multipart mail message using Sendmail.
Invokes Sendmail without involving the shell, so that shell metacharacters won't cause security problems.
send_admin_mail(subject, body)
Sends a mail message to the administrator. hi admin bestie π
read_commands_file()
This function should only be called from "filter_sender" and "filter_recipient". This will read the "COMMANDS" file (as described in mimedefang-protocol(7)), and will fill or update the following global variables: $Sender, @Recipients, %RecipientMailers, $RelayAddr, $RealRelayAddr, $RelayHostname, $RealRelayHostname, $QueueID, $Helo, %SendmailMacros.
If you do not call "read_commands_file", then the only information available in "filter_sender" and "filter_recipient" is that which is passed as an argument to the function. so like, call it, or work with crumbs. your choice. π
π SEE ALSO π
Mail::MIMEDefang::Actions(3)Mail::MIMEDefang::Antispam(3)Mail::MIMEDefang::Antivirus(3)Mail::MIMEDefang::DKIM(3)Mail::MIMEDefang::DKIM::ARC(3)Mail::MIMEDefang::Authres(3)Mail::MIMEDefang::Mail(3)Mail::MIMEDefang::MIME(3)Mail::MIMEDefang::Net(3)Mail::MIMEDefang::RFC2822(3)Mail::MIMEDefang::Unit(3)Mail::MIMEDefang::Utils(3)
and that's the whole page bestie, we ate and left no crumbs π. this was version 3.7.1 from 2026-07-20, filed under Mail::MIMEDefang(3). go filter some mail, you got this ππ¦β¨
π¦ where this page comes from
- fedora 43: mimedefang 3.7.1-1.fc43 Β· GPL-2.0-only AND GPL-2.0-or-later
- fedora 44: mimedefang 3.7.1-1.fc44 Β· GPL-2.0-only AND GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms