mime-msg-builder
is a Rust library for building MIME Messages.
The core feature of the library is the Rust implementation of the Emacs MML module:
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.
```eml From: alice@localhost To: bob@localhost Subject: MML simple
<#multipart type=alternative> This is a plain text part. <#part type=text/enriched>
compiles to:
```eml Subject: MML simple To: bob@localhost From: alice@localhost MIME-Version: 1.0 Date: Tue, 29 Nov 2022 13:07:01 +0000 Content-Type: multipart/alternative; boundary="4CV1Cnp7mXkDyvb55i77DcNSkKzB8HJzaIT84qZe"
--4CV1Cnp7mXkDyvb55i77DcNSkKzB8HJzaIT84qZe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit
This is a plain text part. --4CV1Cnp7mXkDyvb55i77DcNSkKzB8HJzaIT84qZe Content-Type: text/enriched Content-Transfer-Encoding: 7bit
From the documentation:
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.
See
./examples
:
sh
cargo run --example
<#multipart>…<#/multipart>
<#part>…<#/part>
<#part filename=…>
gpg
--encrypt --armor --recipient <recipient> --quiet --output -
)gpg --sign
--armor --quiet --output -
)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
…
```sh
$ nix-shell
$ cargo build ```
If you find a bug, feel free to open an issue at ~soywod/mime-msg-builder.
If you have a feature in mind, feel free to send a patchset at
https://git.sr.ht/~soywod/mime-msg-builder/send-email or use the
command git send-email
.
You can also contact me directly on Matrix at @soywod:matrix.org.