MIMEDEFANG(8)
πΈ MIMEDEFANG(8) πΈ
okay bestie, sit down, hydrate, because we're talking about mimedefang β the Sendmail MIME mail filter, from the System Manager's Manual. yes, section 8. yes, it's a whole thing. but it's a good thing. π«Ά
β¨ SYNOPSIS β¨
mimedefang prcap
mimedefang -p connection -m mx_socket_name -U user [options]
like, that's the whole vibe. two shapes. pick one. π
π DESCRIPTION π
so mimedefang is a filter, right, and it's built around Sendmail 8.11's milter API β that's the API for mail filters, iykyk. what it does: it collects each incoming message and runs a filter on it. and why do we care? because this is genuinely useful for deleting attachments that could be a security risk on poorly-designed systems like Microsoft Windows. no shade, just facts. π
here's the plot twist though β mimedefang does not actually run the Perl filter itself. nope. instead it talks to mimedefang-multiplexor(8), which manages a pool of persistent Perl processes. that's the whole relationship dynamic. go read the mimedefang-multiplexor man page for the extra tea. π
π OPTIONS π
okay so if you invoke mimedefang with the single argument prcap, it prints info about the version of Milter it's linked against and then exits. slay. otherwise, you invoke it like the second line of the SYNOPSIS says. no other options, bestie.
-Uuser β runsmimedefangas user instead of root. β οΈ and the user argument has to match the argument you gave tomimedefang-multiplexor's-Uoption too. they have to agree, they're a package deal.-yβ if you give this command-line option, MIMEDefang will callsmfi_setsymlistto set the list of macros it wants. but heads up: this function leaked memory in versions of Sendmail prior to 8.14.4, so by default we do not call it. if you're running an older version of sendmail, you should explicitly set the list of macros you want in the Sendmail configuration file. β¨-zspooldir β set the spool directory to spooldir. if you skip this option, the spool directory defaults to/var/spool/MIMEDefang.-pconnection β the-pswitch is required and it specifies the milter connection type. typically you should runmimedefangon the same computer as sendmail, which means you should use a UNIX-domain socket for the connection type. the suggested value for-pismimedefang.sockunder the spool directory. π₯-mmx_socket_name β specifies the socket for communicating withmimedefang-multiplexor(8). the mx_socket_name is the path of the UNIX-domain socket. seemimedefang-multiplexor(8)for the details.-bbacklog β sets the "backlog" argument to thelisten(2)system call to backlog. if you omit this option, the operating-system default backlog gets used.-Gβ normallymimedefanguses a umask of077when creating the milter socket and files. if you want the socket to be readable and writeable by the group, and files to be group-readable, supply-G. this causes the umask to be007whenever UNIX-domain sockets are created and027whenever files are created. note: if your milter library is too old to have thesmfi_opensocket()function, the-Goption causesmimedefangto use a umask of007throughout its execution.
also note that by default, /var/spool/MIMEDefang is created with mode 0700. if you use -G, you probably should change the mode to 0750.
-dβ this switch causesmimedefangnot to delete the temporary spool files it creates for incoming messages. > this is for debugging purposes only and should never be used on a production mail server. π¨-rβ causesmimedefangto perform a relay check before processing any messages. it calls into a user-supplied Perl function calledfilter_relaywith the IP address and host name of the sending relay. (seemimedefang-filter(5)for details.)-Hβ causesmimedefangto perform a HELO check before processing any messages. it calls into a user-supplied Perl function calledfilter_helowith the IP address and host name of the sending relay, and the HELO argument. (seemimedefang-filter(5)for details.)-sβ causesmimedefangto perform a sender check before processing the message body. it calls into a user-supplied Perl function calledfilter_senderwith the envelope address of the sender. (seemimedefang-filter(5)for details.)-tβ causesmimedefangto perform recipient checks before processing the message body. it calls into a user-supplied Perl function calledfilter_recipientwith the envelope address of each recipient. (seemimedefang-filter(5)for details.)-qβ permits the multiplexor to queue new connections. see the section QUEUEING REQUESTS in themimedefang-multiplexorman page. note that this option and the-Roption are mutually-exclusive β if you supply-q, then-Ris ignored. π-kβ causesmimedefangnot to delete working directories if a filter fails. this lets you obtain the message which caused the filter to fail and figure out what went wrong.mimedefanglogs the directory containing the failed message using syslog.-PfileName β causesmimedefangto write its process-ID (after becoming a daemon) to the specified file. the file will be owned by root. π-ofileName β causesmimedefangto use fileName as a lock file to avoid multiple instances from running. if you supply-Pbut not-o, thenmimedefangconstructs a lock file by appending".lock"to the pid file. however, that's less secure than having a root-owned pid file in a root-owned directory and a lock file writable by the user named by the-Uoption. (the lock file must be writable by the-Uuser.)-Rnum β normally,mimedefangtempfails a new SMTP connection if there are no free workers. supplying-Rnum makesmimedefangtempfail new connections if there are fewer than num free workers, unless the connection is from the local host. this lets you favour connections from localhost so your clientmqueue doesn't build up. note that supplying-R 0is subtly different from omitting the option; in this case,mimedefangpermits new connections from localhost to queue, but not connections from other hosts (unless you also supply the-qoption.)
the purpose of -R is to reserve resources for clientmqueue runs. otherwise, on a very busy mail server, clientmqueue runs can starve for a long time, leading to delays for locally-generated or streamed mail. we recommend using a small number for num; probably no more than 3 or 10% of the total number of workers (whichever is smaller.)
note that this option and the -q option are mutually-exclusive. if you supply -q, then -R is ignored. π«Ά
-Cβ conserve file descriptors by opening and closing disk files more often. (disk files are never held open across Milter callbacks.) while this shortens the length of time a file descriptor is open, it also leaves more opportunities for the open to fail. we do not recommend this flag except on very busy systems that exhibit failures due to a shortage of file descriptors.-Tβ causesmimedefangto log the run-time of the Perl filter using syslog. β±οΈ-xstring β add string as the content of theX-Scanned-By:header. if you set string to the empty string (i.e.-x ""), then noX-Scanned-By:header will be added.-Xβ do not add anX-Scanned-By:header. specifying-Xis equivalent to specifying-x "".-Dβ do not fork into the background and become a daemon. instead, stay in the foreground. useful mainly for debugging or if you have a supervisory process managingmimedefang.-Mβ this option is obsolete; it's accepted for backward-compatibility, but it's ignored. it's giving legacy. π-Nβ normallymimedefangsees all envelope recipients, even ones that Sendmail knows to be invalid. if you don't want Sendmail to perform a milter callback for recipients it knows to be invalid, invokemimedefangwith the-Nflag. > please note that this flag only works with Sendmail and Milter 8.14.0 and newer. it has no effect if you're running an older version of Sendmail or Milter.-Sfacility β specifies the syslog facility for log messages. the default ismail. seeopenlog(3)for a list of valid facilities. you can use either the short name ("mail") or long name ("LOG_MAIL") for the facility name.-amacro β pass the value of the specified Sendmail macro through to the Perl filter. you can repeat the-aoption to write more macros than the built-in defaults. note that in addition to askingmimedefangto pass the macro value to the filter, you must configure Sendmail to pass the macro through tomimedefangusing theconfMILTER_MACROS_ENVFROMdefinition in Sendmail's m4 configuration file. β¨-cβ strip "bare" carriage-returns (CR) characters from the message body. a bare CR should never appear in an e-mail message. older versions ofmimedefangused to strip them out automatically, but now they're left in by default. the-coption enables the older behavior.-hβ print usage information and exit. short, sweet, iconic. π
π OPERATION π
when mimedefang starts, it connects to sendmail using the milter API. (see the Sendmail 8.11 documentation.) for each incoming message, mimedefang creates a temporary directory and saves information in the directory. at various phases during the SMTP conversation, mimedefang communicates with mimedefang-multiplexor to perform various operations. mimedefang-multiplexor manages a pool of persistent Perl processes that actually perform the mail scanning operations.
when a Perl process scans an e-mail, the temporary spool directory contains certain files; details of the communication protocol between mimedefang and the Perl script are in mimedefang-protocol(7). π¦
π WARNINGS π
mimedefang does violence to the flow of e-mail.
no like, that's literally what it says and honestly? it's not wrong. the Perl filter is quite picky and assumes that MIME e-mail messages are well-formed. while I have tried to make the script safe, I take no responsibility for lost or mangled e-mail messages or any security holes this script may introduce. π read that again. okay. now we can be friends.
π AUTHOR π
mimedefang was written by Dianne Skoll <dfs@roaringpenguin.com>. the mimedefang home page is http://www.mimedefang.org/. absolute main character energy, we love her, no cap. π
π§ SEE ALSO π§
mimedefang.pl(8)mimedefang-filter(5)mimedefang-multiplexor(8)mimedefang-protocol(7)mimedefang-release(8)
okay that's the whole page bestie, you ate it, periodt π β¨
one last lil sign-off from the group chat: this was the 4th Berkeley Distribution version, dated 8 February 2005, and it lives in the MIMEDEFANG(8) manual slot. cute, iconic, historic. ππ¦π
π¦ where this page comes from
- debian trixie: mimedefang 3.6-2 Β· GPL-2.0-only
- epel 10: mimedefang 3.7.1-1.el10_3 Β· GPL-2.0-only AND GPL-2.0-or-later
- epel 9: mimedefang 3.7.1-1.el9 Β· GPL-2.0-only AND GPL-2.0-or-later
- fedora 43: mimedefang 3.6-3.fc43 Β· GPL-2.0-only AND GPL-2.0-or-later
- fedora 43: mimedefang 3.7.1-1.fc43 Β· GPL-2.0-only AND GPL-2.0-or-later
- fedora 44: mimedefang 3.6-4.fc44 Β· 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
- ubuntu questing: mimedefang 3.6-2.1
- ubuntu resolute: mimedefang 3.6-2.1build1 Β· GPL-2.0-only
- ubuntu stonking: mimedefang 3.6-2.1build2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms