magic.lambda.mime
9.9.8
See the version list below for details.
dotnet add package magic.lambda.mime --version 9.9.8
NuGet\Install-Package magic.lambda.mime -Version 9.9.8
<PackageReference Include="magic.lambda.mime" Version="9.9.8" />
paket add magic.lambda.mime --version 9.9.8
#r "nuget: magic.lambda.mime, 9.9.8"
// Install magic.lambda.mime as a Cake Addin #addin nuget:?package=magic.lambda.mime&version=9.9.8 // Install magic.lambda.mime as a Cake Tool #tool nuget:?package=magic.lambda.mime&version=9.9.8
Magic Lambda MIME
Magic Lambda MIME give you the ability to parse and create MIME messages from Hyperlambda. It contains the following slots.
- [mime.parse] - Parses a MIME message, and returns it as a lambda object
- [.mime.parse] - Parses a native MimeEntity for you, and returns it as a lambda object (not for usage directly from Hyperlambda code)
- [mime.create] - Creates a MIME message for you, and returns the entire message as text, being the MIME entity
- [.mime.create] - Creates a MIME message for you, and returns it as a native MimeEntity object (not for usage directly from Hyperlambda code)
- [pgp.keys.private.import] - Imports an ASCII armored private PGP key bundle, in addition to any public keys found in the bundle
- [pgp.keys.public.import] - Imports an ASCII armored public PGP key bundle
Notice - The PGP related slots above are currently in BETA implementation, and their API might change in a future version of Magic.
Parsing MIME messages
Below is an example of how parsing a MIME message might look like.
// Actual message
.msg:@"MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary=""XXXXboundary text""
This is a multipart message in MIME format.
--XXXXboundary text
Content-Type: text/plain
this is the body text
--XXXXboundary text
Content-Type: text/plain;
this is another body text
--XXXXboundary text--"
// Parsing the above message
mime.parse:x:@.msg
After evaluating the above, you'll end up with something resembling the following.
mime.parse
entity:multipart/mixed
headers
MIME-Version:1.0
entity:text/plain
content:this is the body text
entity:text/plain
content:this is another body text
Notice how the slot creates a tree structure, perfectly resembling your original MIME message. It will also take care of MIME headers for you, adding these into a [headers] collection, on a per message basis, depending upon whether or not your message actually contains headers or not.
The [.mime.parse] semantically works identically, except it requires as its input a raw MimeEntity
object from MimeKit.
The [.mime.parse] slot can only be invoked from C#, since it starts with a ".".
Creating a mime message
This slot is logically the exact opposite of the [mime.parse] slot, and can take (almost) the exact same input as its sibling produces as output. Below is an example.
mime.create
entity:multipart/mixed
entity:text/plain
content:this is the body text
entity:text/plain
content:this is another body text
Which of course wil result in something resembling the following after evaluation.
mime.create:@"MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary=""XXXXboundary text""
This is a multipart message in MIME format.
--XXXXboundary text
Content-Type: text/plain
this is the body text
--XXXXboundary text
Content-Type: text/plain;
this is another body text
--XXXXboundary text--"
The [.mime.create] slot, will semantically do the exact same thing, but instead of returning a piece of text,
being the MIME message, it will produce a raw MimeEntity
that it returns to caller. This slot is used internally
when the "magic.lambda.mail" project constructs emails to send over an SMTP connection for instance. This slot
can also only be invoked from C# since it starts with a period (.) as its name.
PGP Cryptography
Notice - These parts of the project is currently in BETA implementation, and the API might change in a future version of Magic.
This project also supports encrypting, and cryptographically signing MIME messages, in addition to verifying signed messages. To cryptographically sign a MIME message with your private PGP key, you can use something such as follows.
mime.create
entity:text/plain
sign:@"-----BEGIN PGP PRIVATE KEY BLOCK----- ...... etc"
password:your-pgp-key-password-here
content:Foo bar
To encrypt a message you could do something such as follows.
mime.create
entity:text/plain
encrypt:@"-----BEGIN PGP PUBLIC KEY BLOCK----- ..... etc"
content:Foo bar
You can encrypt and sign the message in one go, by adding both a private [sign] key and its password, in addition to a public encryption key, using [encrypt]. If you wish to encrypt the same message for multiple recipients, you can add a collection of public PGP keys that will be used to encrypt the message, such as the following illustrates.
mime.create
entity:text/plain
encrypt
.:@"-----BEGIN PGP PUBLIC KEY BLOCK----- ..... etc, key 1"
.:@"-----BEGIN PGP PUBLIC KEY BLOCK----- ..... etc, key 2"
content:Foo bar
Notice - Due to an API flaw in MimeKit, and how it looks up private PGP keys during parsing end decrypting of MIME messages, the project does not support decrypting of messages yet. Once MimeKit implements alternative PGP key storages, or at least hooks to supply your own custom storage, not tied to Gnu Privacy Guard, we might reconsider and support decrypting of MIME messages.
Importing public and private PGP keys
Notice, these slots expects a PGP key bundle, either private or public, and will unwrap each public and private key found in the bundle, and invoke your [.lambda] callback once for each key found in the bundle. This callback will be given the fingerprint, ID, ids, etc for each key in your bundle. Usage is something as follows.
pgp.keys.public.import:@"-----BEGIN PGP PUBLIC KEY BLOCK----- ..... etc"
.lambda
lambda2hyper:x:.
log.info:x:-
The API for importing private keys is the exact same as for importing public keys.
Project website
The source code for this repository can be found at github.com/polterguy/magic.lambda.mime, and you can provide feedback, provide bug reports, etc at the same place.
Quality gates
License
This project is the copyright(c) 2020-2021 of Thomas Hansen thomas@servergardens.com, and is licensed under the terms of the LGPL version 3, as published by the Free Software Foundation. See the enclosed LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- magic.node.extensions (>= 9.9.3)
- magic.signals.contracts (>= 9.9.3)
- MimeKit (>= 2.15.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on magic.lambda.mime:
Package | Downloads |
---|---|
magic.library
Helper project for Magic to wire up everything easily by simply adding one package, and invoking two simple methods. When using Magic, this is (probably) the only package you should actually add, since this package pulls in everything else you'll need automatically, and wires up everything sanely by default. To use package go to https://polterguy.github.io |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
17.2.0 | 473 | 1/22/2024 |
17.1.7 | 193 | 1/12/2024 |
17.1.6 | 156 | 1/11/2024 |
17.1.5 | 193 | 1/5/2024 |
17.0.1 | 207 | 1/1/2024 |
17.0.0 | 377 | 12/14/2023 |
16.11.5 | 321 | 11/12/2023 |
16.9.0 | 337 | 10/9/2023 |
16.7.0 | 564 | 7/11/2023 |
16.4.1 | 369 | 7/2/2023 |
16.4.0 | 363 | 6/22/2023 |
16.3.1 | 309 | 6/7/2023 |
16.3.0 | 322 | 5/28/2023 |
16.1.9 | 619 | 4/30/2023 |
15.10.11 | 465 | 4/13/2023 |
15.9.1 | 608 | 3/27/2023 |
15.9.0 | 454 | 3/24/2023 |
15.8.2 | 485 | 3/20/2023 |
15.7.0 | 396 | 3/6/2023 |
15.5.0 | 1,603 | 1/28/2023 |
15.2.0 | 641 | 1/18/2023 |
15.1.0 | 1,137 | 12/28/2022 |
14.5.7 | 693 | 12/13/2022 |
14.5.5 | 782 | 12/6/2022 |
14.5.1 | 655 | 11/23/2022 |
14.5.0 | 592 | 11/18/2022 |
14.4.5 | 687 | 10/22/2022 |
14.4.1 | 764 | 10/22/2022 |
14.4.0 | 654 | 10/17/2022 |
14.3.1 | 1,272 | 9/12/2022 |
14.3.0 | 619 | 9/10/2022 |
14.1.3 | 934 | 8/7/2022 |
14.1.2 | 656 | 8/7/2022 |
14.1.1 | 633 | 8/7/2022 |
14.0.14 | 677 | 7/26/2022 |
14.0.12 | 652 | 7/24/2022 |
14.0.11 | 630 | 7/23/2022 |
14.0.10 | 651 | 7/23/2022 |
14.0.9 | 642 | 7/23/2022 |
14.0.8 | 703 | 7/17/2022 |
14.0.5 | 791 | 7/11/2022 |
14.0.4 | 765 | 7/6/2022 |
14.0.3 | 721 | 7/2/2022 |
14.0.2 | 675 | 7/2/2022 |
14.0.0 | 828 | 6/25/2022 |
13.4.0 | 2,062 | 5/31/2022 |
13.3.4 | 1,448 | 5/9/2022 |
13.3.0 | 941 | 5/1/2022 |
13.2.0 | 1,158 | 4/21/2022 |
13.1.0 | 1,020 | 4/7/2022 |
13.0.0 | 710 | 4/5/2022 |
11.0.5 | 1,413 | 3/2/2022 |
11.0.4 | 756 | 2/22/2022 |
11.0.3 | 779 | 2/9/2022 |
11.0.2 | 793 | 2/6/2022 |
11.0.1 | 751 | 2/5/2022 |
10.0.21 | 750 | 1/28/2022 |
10.0.20 | 743 | 1/27/2022 |
10.0.19 | 768 | 1/23/2022 |
10.0.18 | 738 | 1/17/2022 |
10.0.15 | 936 | 12/31/2021 |
10.0.14 | 542 | 12/28/2021 |
10.0.7 | 1,494 | 12/22/2021 |
10.0.5 | 759 | 12/18/2021 |
10.0.2 | 660 | 12/14/2021 |
10.0.0 | 639 | 12/6/2021 |
9.9.9 | 1,025 | 11/29/2021 |
9.9.8 | 361 | 11/27/2021 |
9.9.3 | 1,090 | 11/9/2021 |
9.9.2 | 796 | 11/4/2021 |
9.9.0 | 901 | 10/30/2021 |
9.8.9 | 874 | 10/29/2021 |
9.8.7 | 846 | 10/27/2021 |
9.8.6 | 826 | 10/27/2021 |
9.8.5 | 893 | 10/26/2021 |
9.8.0 | 1,624 | 10/20/2021 |
9.7.9 | 762 | 10/19/2021 |
9.7.5 | 1,692 | 10/14/2021 |
9.7.0 | 1,097 | 10/9/2021 |
9.6.6 | 416 | 8/14/2021 |
9.5.3 | 3,659 | 7/20/2021 |
9.2.0 | 4,502 | 5/26/2021 |
9.1.4 | 1,480 | 4/21/2021 |
9.1.0 | 1,241 | 4/14/2021 |
9.0.0 | 1,066 | 4/5/2021 |
8.9.9 | 1,206 | 3/30/2021 |
8.9.3 | 1,730 | 3/19/2021 |
8.9.2 | 1,221 | 1/29/2021 |
8.9.1 | 1,243 | 1/24/2021 |
8.9.0 | 1,298 | 1/22/2021 |
8.6.9 | 3,141 | 11/8/2020 |
8.6.6 | 2,079 | 11/2/2020 |
8.6.0 | 4,214 | 10/28/2020 |
8.5.0 | 2,121 | 10/23/2020 |
8.4.0 | 5,711 | 10/13/2020 |
8.3.1 | 2,868 | 10/5/2020 |
8.3.0 | 1,454 | 10/3/2020 |
8.2.2 | 2,265 | 9/26/2020 |
8.2.1 | 1,502 | 9/25/2020 |
8.2.0 | 1,449 | 9/25/2020 |
8.1.18 | 517 | 9/24/2020 |
8.1.17 | 7,353 | 9/13/2020 |
8.1.16 | 586 | 9/13/2020 |
8.1.15 | 2,315 | 9/12/2020 |
8.1.11 | 2,703 | 9/11/2020 |
8.1.10 | 1,518 | 9/6/2020 |
8.1.9 | 1,494 | 9/3/2020 |
8.1.8 | 1,533 | 9/2/2020 |
8.1.7 | 1,382 | 8/28/2020 |
8.1.4 | 1,396 | 8/25/2020 |
8.1.3 | 1,518 | 8/18/2020 |
8.1.2 | 1,418 | 8/16/2020 |
8.1.1 | 1,442 | 8/15/2020 |
8.1.0 | 561 | 8/15/2020 |
8.0.1 | 3,060 | 8/7/2020 |
8.0.0 | 1,426 | 8/7/2020 |
7.0.1 | 548 | 6/28/2020 |
7.0.0 | 2,403 | 6/28/2020 |
5.0.1 | 3,779 | 5/29/2020 |
5.0.0 | 557 | 5/29/2020 |