{"id":21970670,"url":"https://github.com/sirwumpus/milter-length","last_synced_at":"2026-01-05T05:03:39.830Z","repository":{"id":178660953,"uuid":"662184620","full_name":"SirWumpus/milter-length","owner":"SirWumpus","description":"Reject mail according to different message size limits per IP, domain name, or sender address.","archived":false,"fork":false,"pushed_at":"2024-06-21T19:25:49.000Z","size":82,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T22:43:42.211Z","etag":null,"topics":["milter","postfix","sendmail"],"latest_commit_sha":null,"homepage":"","language":"M4","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SirWumpus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.TXT","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-04T14:34:50.000Z","updated_at":"2024-06-21T19:25:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a521f3a-d28c-4302-96e2-484e4d760265","html_url":"https://github.com/SirWumpus/milter-length","commit_stats":null,"previous_names":["sirwumpus/milter-length"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/SirWumpus/milter-length","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SirWumpus%2Fmilter-length","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SirWumpus%2Fmilter-length/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SirWumpus%2Fmilter-length/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SirWumpus%2Fmilter-length/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SirWumpus","download_url":"https://codeload.github.com/SirWumpus/milter-length/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SirWumpus%2Fmilter-length/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28213986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-05T02:00:06.358Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["milter","postfix","sendmail"],"created_at":"2024-11-29T14:41:42.443Z","updated_at":"2026-01-05T05:03:39.810Z","avatar_url":"https://github.com/SirWumpus.png","language":"M4","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![SnertSoft: We Serve Your Server](Img/logo-300x74.png)](http://software.snert.com/)\n\nmilter-length  « When Size Matters »\n====================================\n\nCopyright 2004, 2024 by Anthony Howe.  All rights reserved.\n\n\nWARNING\n-------\n\nTHIS IS MAIL FILTERING SOFTWARE AND WILL BLOCK MAIL THAT FAILS TO PASS A GIVEN SET OF TESTS.  SNERTSOFT AND THE AUTHOR DO NOT ACCEPT ANY RESPONSIBLITY FOR MAIL REJECTED OR POSSIBLE LOSS OF BUSINESSS THROUGH THE USE OF THIS SOFTWARE.  BY INSTALLING THIS SOFTWARE THE CLIENT UNDERSTANDS AND ACCEPTS THE RISKS INVOLVED.\n\n\nDescription\n-----------\n\n\nThis is a [Sendmail](http://www.sendmail.org/) utility milter that imposes message size limits by IP address, domain name, or sender address on a message body length, excluding the message headers.  Sendmail's `MaxMessageSize` option only allows for a single global server wide message size limit, which is insufficient for some sites that would prefer finer granularity in the application of message size limits.  This is particularly useful for mail hosts that manage several domains and/or a large number of users, such as an ISP.\n\nNote that if the Sendmail option `MaxMessageSize` is specified in the sendmail.cf configuration, then that will impose an upper limit to any `milter-length` message size limits. \n\n\nUsage\n-----\n\n        milter-length [options ...] [arguments ...]\n\nOptions can be expressed in four different ways.  Boolean options are expressed as `+option` or `-option` to turn the option on or off respectively.  Options that required a value are expressed as `option=value` or `option+=value` for appending to a value list.  Note that the `+option` and `-option` syntax are equivalent to `option=1` and `option=0` respectively.  Option names are case insensitive.\n\nSome options, like `+help` or `-help`, are treated as immediate actions or commands.  Unknown options are ignored.  The first command-line argument is that which does not adhere to the above option syntax.  The special command-line argument `--` can be used to explicitly signal an end to the list of options.\n\nThe default options, as shown below, can be altered by specifying them on the command-line or within an option file, which simply contains command-line options one or more per line and/or on multiple lines.  Comments are allowed and are denoted by a line starting with a hash (#) character.  If the `file=` option is defined and not empty, then it is parsed first followed by the command-line options.\n\nNote that there may be additional options that are listed in the option summary given by `+help` or `-help` that are not described here.\n\n\n- - -\n### access-db=/etc/mail/access.db\n\nThe type and location of the read-only access key-value map.  It provides a centralised means to black and white list hosts, domains, mail addresses, etc.  The following methods are supported:\n\n        text!/path/map.txt                      R/O text file, memory hash\n        /path/map.db                            Berkeley DB hash format\n        db!/path/map.db                         Berkeley DB hash format\n        db!btree!/path/map.db                   Berkeley DB btree format\n        sql!/path/database                      An SQLite3 database\n        socketmap!host:port                     Sendmail style socket-map\n        socketmap!/path/local/socket            Sendmail style socket-map\n        socketmap!123.45.67.89:port             Sendmail style socket-map\n        socketmap![2001:0DB8::1234]:port        Sendmail style socket-map\n\nIf `:port` is omitted, the default is `7953`.\n\nThe `access-db` contains key-value pairs.  Lookups are performed from most to least specific, stopping on the first entry found.  Keys are case-insensitive.\n\nAn IPv4 lookup is repeated several times reducing the IP address by one octet from right to left until a match is found.\n\n        tag:192.0.2.9\n        tag:192.0.2\n        tag:192.0\n        tag:192\n\nAn IPv6 lookup is repeated several times reducing the IP address by one 16-bit word from right to left until a match is found.\n\n        tag:2001:0DB8:0:0:0:0:1234:5678\n        tag:2001:0DB8:0:0:0:0:1234\n        tag:2001:0DB8:0:0:0:0\n        tag:2001:0DB8:0:0:0\n        tag:2001:0DB8:0:0\n        tag:2001:0DB8:0:0\n        tag:2001:0DB8:0\n        tag:2001:0DB8\n        tag:2001\n\nA domain lookup is repeated several times reducing the domain by one label from left to right until a match is found.\n\n        tag:[ipv6:2001:0DB8::1234:5678]\n        tag:[192.0.2.9]\n        tag:sub.domain.tld\n        tag:domain.tld\n        tag:tld\n        tag:\n\nAn email lookup is similar to a domain lookup, the exact address is first tried, then the address's domain, and finally the local part of the address.\n\n        tag:account@sub.domain.tld\n        tag:sub.domain.tld\n        tag:domain.tld\n        tag:tld\n        tag:account@\n        tag:\n\nIf a key is found and is a milter specific tag (ie. `milter-length-Connect`, `milter-length-To`), then the value is processed as a pattern list and the result returned.  The Sendmail variants cannot have a pattern list.  A pattern list is a whitespace separated list of _pattern-action_ pairs followed by an optional default _action_.  The supported patterns are:\n\n        [network/cidr]size            Classless Inter-Domain Routing\n        !pattern!size                 Simple fast text matching.\n        /regex/size                   POSIX Extended Regular Expressions\n\nThe CIDR will only ever match for IP address related lookups.\n\nA `!pattern!` uses an astrisk (\\*) for a wildcard, scanning over zero or more characters; a question-mark (?) matches any single character; a backslash followed by any character treats it as a literal (it loses any special meaning).\n\n        !abc!           exact match for 'abc'\n        !abc*!          match 'abc' at start of string\n        !*abc!          match 'abc' at the end of string\n        !abc*def!       match 'abc' at the start and match 'def' at the end, maybe with stuff in between.\n        !*abc*def*!     find 'abc', then find 'def'\n\nBelow is a list of supported tags.  Other options may specify additional tags.\n\n        milter-length-Connect:client-ip          size           § Can be a pattern list.\n        milter-length-Connect:[client-ip]        size           § Can be a pattern list.\n        milter-length-Connect:client-domain      size           § Can be a pattern list.\n        milter-length-Connect:                   size           § Can be a pattern list.\n\n        milter-length-Auth:auth_authen           size           § Can be a pattern list.\n        milter-length-Auth:                      size           § Can be a pattern list.\n\n        milter-length-From:sender-address        size           § Can be a pattern list.\n        milter-length-From:sender-domain         size           § Can be a pattern list.\n        milter-length-From:sender@               size           § Can be a pattern list.\n        milter-length-From:                      size           § Can be a pattern list.\n\n        milter-length-To:recipient-address       size           § Can be a pattern list.\n        milter-length-To:recipient-domain        size           § Can be a pattern list.\n        milter-length-To:recipient@              size           § Can be a pattern list.\n        milter-length-To:                        size           § Can be a pattern list.\n\nThe _size_ is the maximum number of octets permitted in a message and is expressed as a number with an optional scale suffix: K (kilo), M (mega), or G (giga).  If no size is specified (or -1), then the message can be any length (ULONG_MAX).\n\nWhen there are multiple message size limits assigned, then the limit applied, in order of precedence, will be: the maximum value of all relevant `milter-length-to:`, `milter-length-auth:`, `milter-length-from:`, `milter-length-connect:`, or an unlimited default.  Essentially each matching milter tag replaces the previous value.  When there are multiple recipients with one or more possible `milter-length-to:` entries, then maximum length limit found is applied. \n\nBelow are only some examples of what is possible: \n\n        milter-length-Connect:80.94             [80.94.96.0/20]2M  500K\n \nAll the mail from netblock 80.94.96.0/20 (80.94.96.0 through to 80.94.111.255) is limited to 2 megabytes, while anything else in 80.94.0.0/16 is limited to 500 kilobytes.\n \n        milter-length-Connect:192.0.2           10M\n \nAll the mail from the network in 192.0.2.0/24 is limited to 10 megabytes.\n \n        milter-length-Connect:192.0.2           /^192\\.0\\.2\\.8[0-9]/1M  10M\n\nMail sent from IP addresses 192.0.2.80 through to 192.0.2.89 is limited to 1 megabyte, while the rest of the network in 192.0.2.0/24 is limited to 10 megabytes.  This example is rather contrived to show some of what is possible with patterns and is the equivalent of ten simple `milter-length-connect:` entries.  When using patterns, weigh the need verses simplicity, readability, and administration.\n \n        milter-length-From:example.com          /^[^+]+@/500K\n \nMail from within example.com, where the sender's address does not contain a plus-detail, is limited to 500 kilobytes, otherwise no limit is imposed.\n \n        milter-length-To:example.net            !*+*@*!  /^[0-9].*/20K  !*smith*@*!1M 4M\n \nMail to addresses within `example.net` containing a plus-detail have no limit; those starting with a digit are limited to 20 kilobytes; mail to anyone with \"smith\" as part of their address is limited to 1 megabyte, while the rest of the domain is limited to 4 megabytes. \n\n\n- - -\n### +daemon\n\nStart as a background daemon or foreground application.\n\n\n- - -\n### file=/etc/mail/milter-length.cf\n\nRead the option file before command line options.  This option is set by default.  To disable the use of an option file, simply say `file=''`.\n\n\n- - -\n### -help or +help\n\nWrite the option summary to standard output and exit.  The output is suitable for use as an option file.\n\n\n- - -\n### milter-socket=unix:/var/run/milter/milter-length.socket\n\nA socket specifier used to communicate between Sendmail and `milter-length`.  Typically a unix named socket or a host:port.  This value must match the value specified for the `INPUT_MAIL_FILTER()` macro in the sendmail.mc file.  The accepted syntax is:\n\n        {unix|local}:/path/to/file              A named pipe. (default)\n        inet:port@{hostname|ip-address}         An IPV4 socket.\n        inet6:port@{hostname|ip-address}        An IPV6 socket.\n\n\n- - -\n### milter-timeout=7210\n\nThe sendmail/milter I/O timeout in seconds.\n\n\n- - -\n### pid-file=/var/run/milter/milter-length.pid\n\nThe file path of where to save the process-id.\n\n\n- - -\n### -quit or +quit\n\nQuit an already running instance of the milter and exit.  This is equivalent to:\n\n        kill -QUIT `cat /var/run/milter/milter-length.pid`.\n\n\n- - -\n### -restart or +restart\n\nTerminate an already running instance of the milter before starting.\n\n\n- - -\n### run-group=milter\n\nThe process runtime group name to be used when started by root.\n\n- - -\n### run-user=milter\n\nThe process runtime user name to be used when started by root.\n\n\n- - -\n### -smtp-auth-ok\n\nAllow SMTP authenticated senders to send unscanned mail.  See also the `milter-length-auth:` tag (`access-db=`) for finer granularity of control.\n\n\n- - -\n### verbose=info\n\nA comma separated list of how much detail to write to the mail log.  Those mark with `§` have meaning for this milter.\n\n        §  all          All messages\n        §  0            Log nothing.\n        §  info         General info messages. (default)\n        §  trace        Trace progress through the milter.\n        §  parse        Details from parsing addresses or special strings.\n           debug        Lots of debug messages.\n           dialog       I/O from Communications dialog\n           state        State transitions of message body scanner.\n           dns          Trace \u0026 debug of DNS operations\n           cache        Cache get/put/gc operations.\n        §  database     Sendmail database lookups.\n           socket-fd    socket open \u0026 close calls\n           socket-all   All socket operations \u0026 I/O\n        §  libmilter    libmilter engine diagnostics\n\n\n- - -\n### work-dir=/var/tmp\n\nThe working directory of the process.  Normally serves no purpose unless the kernel option that permits daemon process core dumps is set.\n\n\nSMTP Responses\n--------------\n\nThis is the list of possible SMTP responses:\n\n* 550 5.7.1 max. message size \\([0-9]+\\) exceeded  \n  The message body, not counting the headers, is too big.\n    \n* 553 5.1.0 imbalanced angle brackets in path  \n  The path given for a `MAIL` or `RCPT` command is missing a closing angle bracket\n\n* 553 5.1.0 address does not conform to RFC 2821 syntax  \n  The address is missing the angle brackets, `\u003c` and `\u003e`, as required by the RFC grammar.\n\n* 553 5.1.0 local-part too long  \n  The stuff before the `@` is too long.\n\n* 553 5.1.[37] invalid local part  \n  The stuff before the `@` sign contains unacceptable characters.\n\n* 553 5.1.0 domain name too long  \n  The stuff after the `@` is too long.\n\n* 553 5.1.7 address incomplete  \n  Expecting a domain.tld after the `@` sign and found none.\n\n* 553 5.1.[37] invalid domain name  \n  The domain after the `@` sign contains unacceptable characters.\n\n\nBuild \u0026 Install\n---------------\n\n* Install `SQLite` from a package if desired.  Prior to [LibSnert's](https://github.com/SirWumpus/libsnert) availability on GitHub, the old `libsnert` tarballs included SQLite, but the GitHub [libsnert](https://github.com/SirWumpus/libsnert) repository does not, so it needs to be installed separately.   `milter-length` does not require it, but other milters that need a cache will.\n\n* If you have never built a milter for Sendmail, then please make sure that you build and install `libmilter` (or install a pre-built package), which is _not_ built by default when you build Sendmail.  Please read the `libmilter` documentation.  Briefly, it should be something like this:\n\n        cd (path to)/sendmail-8.13.6/libmilter\n        sh Build -c install\n\n* [Build LibSnert](https://github.com/SirWumpus/libsnert#configuration--build) first, do *not* disable `sqlite3` support; it should find the pre-installed version of SQLite if any.\n\n* Building `milter-length` should be:\n\n        cd com/snert/src\n        git clone https://github.com/SirWumpus/milter-length.git\n        cd milter-length\n        ./configure --help\n        ./configure\n        make\n        sudo make install\n\n* An example `/usr/local/share/examples/milter-length/milter-length.mc` is supplied.  This file should be reviewed and the necessary elements inserted into your Sendmail `.mc` file and `sendmail.cf` rebuilt.  Please note the comments on the general milter flags.\n\n* Once installed and configured, start `milter-length` and then restart Sendmail.  An example startup script is provided in `/usr/local/share/examples/milter-length/milter-length.sh`.\n\n\nNotes\n-----\n\n* The minimum desired file ownership and permissions are as follows for a typical Linux system.  For FreeBSD, NetBSD, and OpenBSD the binary and cache locations may differ, but have the same permissions.  Process user `milter` is primary member of group `milter` and secondary member of group `smmsp`.  Note that the milter should be started as `root`, so that it can create a _.pid file_ and _.socket file_ in `/var/run`; after which it will switch process ownership to `milter:milter` before starting the accept socket thread.\n\n        /etc/mail/                              root:smmsp      0750 drwxr-x---\n        /etc/mail/access.db                     root:smmsp      0640 -rw-r-----\n        /etc/mail/sendmail.cf                   root:smmsp      0640 -rw-r-----\n        /etc/mail/milter-length.cf              root:root       0644 -rw-r--r--\n        /var/run/milter/milter-length.pid       milter:milter   0644 -rw-r--r--\n        /var/run/milter/milter-length.socket    milter:milter   0644 srw-r--r--\n        /var/db/milter-length                   milter:milter   0644 -rw-r--r-- (*BSD)\n        /var/cache/milter-length                milter:milter   0644 -rw-r--r-- (linux)\n        /usr/local/libexec/milter-length        root:milter     0550 -r-xr-x---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsirwumpus%2Fmilter-length","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsirwumpus%2Fmilter-length","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsirwumpus%2Fmilter-length/lists"}