📫 MIME Meta Language
Rust implementation of the Emacs MIME message Meta Language, as known as MML.
This library exposes a MML to MIME message compiler and a MIME to MML message interpreter. See the API documentation for more information.
For example:
From: alice@localhost
To: bob@localhost
Subject: MML example
See attachment!
<#part filename=/path/to/attachment.png>
compiles to:
MIME-Version: 1.0
From: <alice@localhost>
To: <bob@localhost>
Subject: MML example
Message-ID: <17859f79a642d0cf.f9706245cd3a3f97.3b41d60ef9e2fbfb@soywod>
Date: Sun, 17 Sep 2023 07:36:19 +0000
Content-Type: multipart/mixed;
boundary="17859f79a64304be_97a7dbff4c84bbac_3b41d60ef9e2fbfb"
--17859f79a64304be_97a7dbff4c84bbac_3b41d60ef9e2fbfb
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
See attachment!
--17859f79a64304be_97a7dbff4c84bbac_3b41d60ef9e2fbfb
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="attachment.png"
Content-Transfer-Encoding: base64
iVBORw0KGgo…
--17859f79a64304be_97a7dbff4c84bbac_3b41d60ef9e2fbfb--
Definition
From the Emacs documentation:
Creating a MIME message is boring and non-trivial. Therefore, a library called mml has been defined that parses a language called MML (MIME Meta Language) and generates MIME messages.
The MML language is very simple. It looks a bit like an SGML application, but it’s not.
The main concept of MML is the part. Each part can be of a different type or use a different charset. The way to delineate a part is with a ‘<#part ...>’ tag. Multipart parts can be introduced with the ‘<#multipart ...>’ tag. Parts are ended by the ‘<#/part>’ or ‘<#/multipart>’ tags. Parts started with the ‘<#part ...>’ tags are also closed by the next open tag.
[…]
Each tag can contain zero or more parameters on the form ‘parameter=value’. The values may be enclosed in quotation marks, but that’s not necessary unless the value contains white space. So ‘filename=/home/user/#hello$^yes’ is perfectly valid.
Features
- Compile MML messages into MIME messages using
MmlCompiler
builder (cargo featurecompiler
required, enabled by default) - Interpret MIME messages as MML messages using the
MimeInterpreter
builder (cargo featureinterpreter
required, activated by default) - Multiple parts support
<#multipart>…<#/multipart>
- Inline part support
<#part text=mime/type>…<#/part>
- Attachment support
<#part filename=/path/to/attachment.ext>
- Comment support
<#!part>This will not be compiled<#!/part>
- PGP supported by:
- Shell commands (cargo feature
pgp-commands
required) - GPG bindings (cargo feature
pgp-gpg
andgpgme
lib required) - Native Rust implementation (cargo feature
pgp-native
required)
- Shell commands (cargo feature
Examples
See ./examples
:
Development
The development environment is managed by Nix. Running nix-shell
will spawn a shell with everything you need to get started with the lib: cargo
, cargo-watch
, rust-bin
, rust-analyzer
…
# Start a Nix shell
# then build the lib
Contributing
If you want to report a bug that does not exist yet, please send an email at ~soywod/pimalaya@todo.sr.ht.
If you want to propose a feature or fix a bug, please send a patch at ~soywod/pimalaya@lists.sr.ht using git send-email. Follow this guide to configure git properly.
If you just want to discuss about the project, feel free to join the Matrix workspace #pimalaya.mml or contact me directly @soywod. You can also use the mailing list [send an email|subscribe|unsubscribe].
Sponsoring
Special thanks to the NLnet foundation and the European Commission that helped the project to receive financial support from:
- NGI Assure in 2022
- NGI Zero Untrust in 2023
If you appreciate the project, feel free to donate using one of the following providers: