### Install Purepythonmilter from sources Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/src/purepythonmilter/examples/README.md Clones the repository, navigates into the directory, and installs the package with example dependencies. ```console $ git clone https://github.com/gertvdijk/purepythonmilter.git $ cd purepythonmilter # N.B. You may want to create and activate a Python virtualenv at this point. # This installs the package at the current location (`.`) with the `examples` option # to indicate extra dependencies to be installed. $ python -m pip install -e .[examples] ``` -------------------------------- ### Run an example Milter app Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/src/purepythonmilter/examples/README.md Starts the debug_log_all example Milter application, binding it to a specific host and setting the log level. ```console $ python -m purepythonmilter.examples.debug_log_all \ --bind-host 172.17.0.1 \ --log-level=INFO ``` -------------------------------- ### Installing project with development and example dependencies Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/CONTRIBUTING.md Command to install the project in editable mode with extra dependencies for development and examples. ```console $ pip install -e .[development,examples] ``` -------------------------------- ### Build and run Postfix instance in Docker Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/src/purepythonmilter/examples/README.md Uses a Makefile to build and start a Postfix container. ```console $ make -C postfixtest ``` -------------------------------- ### Install Purepythonmilter Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/README.md Install Purepythonmilter using pip. ```console pip install purepythonmilter ``` -------------------------------- ### PurePythonMilter Class Construction Example Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/api.md An example demonstrating how to instantiate the PurePythonMilter class with specified hooks and flags. ```python mymilter = PurePythonMilter( hook_on_connect=my_on_connect, can_add_headers=True, ) ``` -------------------------------- ### Self-descriptive example Milter app Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/README.md A self-descriptive example Milter application demonstrating basic functionality. ```python import purepythonmilter as ppm async def on_mail_from(cmd: ppm.MailFrom) -> ppm.VerdictOrContinue: if cmd.address.lower().endswith("@example.com"): return ppm.RejectWithCode(primary_code=(5, 7, 1), text="not allowed here!") return ppm.Continue() mymilter = ppm.PurePythonMilter(name="mymilter", hook_on_mail_from=on_mail_from) mymilter.run_server(host="127.0.0.1", port=9000) ``` -------------------------------- ### Connect to Postfix using telnet Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/src/purepythonmilter/examples/README.md Initiates a telnet connection to the Postfix instance on port 25. ```console $ telnet "$(make --silent -C postfixtest get-ipv4)" 25 ``` -------------------------------- ### Get Postfix container IPv4 address Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/src/purepythonmilter/examples/README.md Retrieves the IPv4 address of the running Postfix Docker container. ```console $ make --silent -C postfixtest get-ipv4 ``` -------------------------------- ### Send email using SWAKS Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/src/purepythonmilter/examples/README.md A one-liner command to send an email using SWAKS to the Postfix instance. ```console $ swaks --to user@test.local --server $(make --silent -C postfixtest get-ipv4) ``` -------------------------------- ### Macro Definition Example Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/milter-protocol.md An example of how DEFINE_MACRO commands with multiple symbols are encoded, including NULL termination and separation, and how symbols longer than a single character are wrapped in braces. ```text C{mysymbol}NULLmyvalueNULL{othersymbol}NULLothervalueNULLiNULLABCD1234NULL ``` -------------------------------- ### SMTP Server Greeting Example Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/smtp-recap.md An example of the initial greeting message from an SMTP server. ```text 220 myhost.g3rt.nl ESMTP Postfix (Debian/GNU) ``` -------------------------------- ### Running the all-linters script Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/CONTRIBUTING.md Command to execute the run-all-linters script and shows an example of successful output. ```console $ ./run-all-linters [...] Everything looks OK! 🎉 ``` -------------------------------- ### Running pytest to verify tests Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/CONTRIBUTING.md Command to execute all tests using pytest and shows an example of successful output. ```console $ pytest [...] ==== 211 passed in 1.09s ==== ``` -------------------------------- ### Example of well-crafted commits Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/CONTRIBUTING.md Illustrates a structured approach to commit history for a pull request. ```git HEAD Implement feature X -- the aim of the pull request HEAD^ Refactor module Y to allow for subclassing ClassZ -- improvement, but preparatory change HEAD^^ Add tests for current logic in module Y -- not a functional change in itself, but purely preparatory to assert a before-change state is tested for. ``` -------------------------------- ### Options Negotiate Symbols List Encoding Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/milter-protocol.md Example encoding for the Options negotiate response, including macro stage ID and a space-separated list of symbols, NULL-terminated. ```text \x00\x00\x00\x01j {my}\x00\x00\x00\x00\x00\x03k {other}\x00\x00 ``` -------------------------------- ### Setting up the development environment with direnv Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/CONTRIBUTING.md Commands to link the .envrc-example and allow direnv to manage the virtual environment. ```console $ ln -s .envrc-example .envrc $ direnv allow ``` -------------------------------- ### Applying the Apache License Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/LICENSES/Apache-2.0.txt This snippet shows how to apply the Apache License to your work by including a boilerplate notice. ```text Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. ``` -------------------------------- ### Upgrading base Python packages Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/CONTRIBUTING.md Command to ensure pip, setuptools, and setuptools-scm are up-to-date within the virtual environment. ```console $ pip install --upgrade pip setuptools setuptools-scm[toml] ``` -------------------------------- ### Create an annotated and signed git tag Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/releasing.md Steps to create a signed git tag for a release. ```console $ git status # Should show 'nothing to commit, working tree clean' $ git branch --all --contains HEAD $ git tag --annotate --sign --message="" ``` -------------------------------- ### Build source distribution and wheel Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/releasing.md Build a Python source distribution file and a wheel using the 'build' tool. ```console $ rm -rf dist/ $ python -m build $ ls -l dist/ ``` -------------------------------- ### Upload to PyPI testing and verify Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/releasing.md Upload packages to the test PyPI repository and verify the release. ```console $ twine check --strict dist/* $ TWINE_USERNAME=__token__ twine upload --sign --repository testpypi dist/* ``` -------------------------------- ### Check wheel contents Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/releasing.md Run the 'check-wheel-contents' linter on the built wheel. ```console $ check-wheel-contents dist/purepythonmilter-*.whl ``` -------------------------------- ### Upload to regular PyPI Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/releasing.md Upload the release packages to the regular PyPI repository. ```console $ TWINE_USERNAME=__token__ twine upload --sign dist/* ``` -------------------------------- ### Checking for outdated packages Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/CONTRIBUTING.md Command to list any outdated packages in the current virtual environment. ```console $ pip list --outdated ``` -------------------------------- ### Push git tag to GitHub Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/releasing.md Push the created git tag to the GitHub repository. ```console $ git push refs/tags/:refs/tags/ ``` -------------------------------- ### Generate SHA256SUMS file Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/releasing.md Generate a SHA256SUMS file for the distribution files and verify it. ```console $ (cd dist/ \ && sha256sum purepythonmilter-*.{tar.gz,whl} > SHA256SUMS \ && sha256sum --check SHA256SUMS) ``` -------------------------------- ### SMFIC_QUIT_NC Command Definition Source: https://github.com/gertvdijk/purepythonmilter/blob/develop/docs/milter-protocol.md Defines the SMFIC_QUIT_NC command in Sendmail's libmilter, which suggests reusing the connection. ```c #define SMFIC_QUIT_NC 'K' /* QUIT but new connection follows * ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.