magic.lambda.mail
10.0.7
See the version list below for details.
dotnet add package magic.lambda.mail --version 10.0.7
NuGet\Install-Package magic.lambda.mail -Version 10.0.7
<PackageReference Include="magic.lambda.mail" Version="10.0.7" />
paket add magic.lambda.mail --version 10.0.7
#r "nuget: magic.lambda.mail, 10.0.7"
// Install magic.lambda.mail as a Cake Addin #addin nuget:?package=magic.lambda.mail&version=10.0.7 // Install magic.lambda.mail as a Cake Tool #tool nuget:?package=magic.lambda.mail&version=10.0.7
Magic Lambda Mail
SMTP and POP3 helpers for Magic. More specifically, this project contains the following slots.
- [mail.smtp.send] - Sends email(s) through an SMTP server
- [mail.pop3.fetch] - Retrieves emails from a POP3 server
Both of the above slots have async overrides that will be automatically used by Magic if possible.
Sending email(s)
mail.smtp.send
server
host:foo.com
port:123
secure:true
username:xxx
password:yyy
message
to
John Doe:john@doe.com
from
Jane Doe:jane@doe.com
subject:Subject line
entity:text/plain
content:Body content
You can send multiple [message] objects at the same time, using the same SMTP connection and credentials. This allows you to connect once to the SMTP server, and use the same connection to send multipl emails.
The entirety of the [server] node above is optional, and if it's not given, it will be fetched from your
configuration settings. You can also override only one or two parts in your [server] segment above, and
have the system read the rest of the settings from your application's configuration. In addition, the [from]
node is also optional, assuming you have a default from
configured in your configuration settings. Below are
the keys used to fetch configuration settings for SMTP connections, and from object, if not explicitly given as
part of the invocation.
- magic.smtp.host
- magic.smtp.port
- magic.smtp.secure
- magic.smtp.username
- magic.smtp.password
- magic.smtp.from.name
- magic.smtp.from.address
An example of how your configuration might look like, if you choose to use configuration settings, instead of having to supply server configuration every time you invoke the slot, can be found below.
{
"magic":{
"smtp":{
"host":"smtp.gmail.com",
"port":465,
"secure":true,
"username":"username@gmail.com",
"password":"gmail-password",
"from": {
"name":"John Doe",
"address":"john@doe.com"
}
}
}
}
FYI - If you exchange the above username/password combination, and open your GMail account for "insecure apps", the above will allow you to send emails using your GMail account.
Assuming you have the above somewhere in your configuration, you can construct and send an email using something like the following. Which probably makes things more convenient, allowing you to avoid thinking about connection settings, from addresses, etc - And leave this as a part of your deployment transformation pipeline(s), etc.
mail.smtp.send
message
to
Jane Doe:jane@doe.com
subject:Subject line
entity:text/plain
content:Body content
You can also add [cc] and [bcc] recipients for your emails, using the same structure you're using for [to]. In addition you can attach files to your messages, by instead of adding a [content] node to your invocation, adding a [filename] node, with a relative path pointing to the file you want to attach to your message. Below is an example of an email with a single attachment.
mail.smtp.send
message
to
Jane Doe:jane@doe.com
subject:Subject line
entity:multipart/mixed
entity:text/plain
content:Body content
entity:text/plain
filename:/files/foo.txt
To construct your email's [message] part, see the documentation for the Magic Lambda MIME project.
Retrieving emails
To retrieve emails from a POP3 server is equally easy. Below is an example.
mail.pop3.fetch
server
host:foo.com
port:123
secure:true
username:xxx
password:yyy
max:int:50
raw:bool:false
.lambda
/*
* Some lambda object invoked once for every email fetched.
* Given message as [.message] node structured as lambda.
*/
Just like its SMTP counterpart, the entirety of the above [server] node is optional, and fetched from your configuration if ommitted. Below are the keys used to fetch configuration settings for your POP3 connection, if not explicitly given as part of invocation.
- magic.pop3.host
- magic.pop3.port
- magic.pop3.secure
- magic.pop3.username
- magic.pop3.password
An example of how your configuration might look like, if you choose to use configuration settings, instead of having to supply server configuration every time you invoke the slot, can be found below.
{
"magic":{
"pop3":{
"host":"pop.gmail.com",
"port":995,
"secure":true,
"username":"username@gmail.com",
"password":"gmail-password",
}
}
}
FYI - If you exchange the above username/password combination, and open up your GMail account for "insecure apps", the above will allow you to send emails using your GMail account.
Notice, if [raw] is true, the message will not be parsed and turned into a structural lambda object, but passed into your [.lambda] as its raw MIME message instead. The default value for [raw] is false.
Your [.lambda] callback will be invoked for each message with a [.message] node, containing the structured/raw version of the MIME message wrapping the actual email message. Refer to the Magic Lambda MIME project documentation for details to understand this structure. If you choose to retrieve messages in [raw] format, the message node's value will contain the raw MIME message as text. If you choose this path, and you later want to actually parse the message, to make it become a structured lambda object - You can use the [mime.parse] slot from Magic Lambda MIME.
Project website
The source code for this repository can be found at github.com/polterguy/magic.lambda.mail, 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 Aista, Ltd 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 (>= 10.0.7)
- magic.signals.contracts (>= 10.0.7)
- MailKit (>= 3.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on magic.lambda.mail:
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 | 445 | 1/22/2024 |
17.1.7 | 194 | 1/12/2024 |
17.1.6 | 159 | 1/11/2024 |
17.1.5 | 170 | 1/5/2024 |
17.0.1 | 209 | 1/1/2024 |
17.0.0 | 343 | 12/14/2023 |
16.11.5 | 328 | 11/12/2023 |
16.9.0 | 321 | 10/9/2023 |
16.7.0 | 579 | 7/11/2023 |
16.4.1 | 403 | 7/2/2023 |
16.4.0 | 382 | 6/22/2023 |
16.3.1 | 317 | 6/7/2023 |
16.3.0 | 338 | 5/28/2023 |
16.1.9 | 631 | 4/30/2023 |
15.10.11 | 477 | 4/13/2023 |
15.9.1 | 608 | 3/27/2023 |
15.9.0 | 470 | 3/24/2023 |
15.8.2 | 496 | 3/20/2023 |
15.7.0 | 384 | 3/6/2023 |
15.5.0 | 1,618 | 1/28/2023 |
15.2.0 | 661 | 1/18/2023 |
15.1.0 | 1,159 | 12/28/2022 |
14.5.7 | 734 | 12/13/2022 |
14.5.5 | 821 | 12/6/2022 |
14.5.1 | 673 | 11/23/2022 |
14.5.0 | 605 | 11/18/2022 |
14.4.5 | 710 | 10/22/2022 |
14.4.1 | 766 | 10/22/2022 |
14.4.0 | 655 | 10/17/2022 |
14.3.1 | 1,284 | 9/12/2022 |
14.3.0 | 650 | 9/10/2022 |
14.1.3 | 920 | 8/7/2022 |
14.1.2 | 686 | 8/7/2022 |
14.1.1 | 669 | 8/7/2022 |
14.0.14 | 698 | 7/26/2022 |
14.0.12 | 667 | 7/24/2022 |
14.0.11 | 659 | 7/23/2022 |
14.0.10 | 658 | 7/23/2022 |
14.0.9 | 645 | 7/23/2022 |
14.0.8 | 742 | 7/17/2022 |
14.0.5 | 802 | 7/11/2022 |
14.0.4 | 764 | 7/6/2022 |
14.0.3 | 719 | 7/2/2022 |
14.0.2 | 682 | 7/2/2022 |
14.0.0 | 867 | 6/25/2022 |
13.4.0 | 2,112 | 5/31/2022 |
13.3.4 | 1,476 | 5/9/2022 |
13.3.0 | 937 | 5/1/2022 |
13.2.0 | 1,176 | 4/21/2022 |
13.1.0 | 1,032 | 4/7/2022 |
13.0.0 | 743 | 4/5/2022 |
12.0.3 | 886 | 3/14/2022 |
11.0.5 | 1,071 | 3/2/2022 |
11.0.4 | 762 | 2/22/2022 |
11.0.3 | 785 | 2/9/2022 |
11.0.2 | 789 | 2/6/2022 |
11.0.1 | 773 | 2/5/2022 |
10.0.21 | 751 | 1/28/2022 |
10.0.20 | 752 | 1/27/2022 |
10.0.19 | 765 | 1/23/2022 |
10.0.18 | 746 | 1/17/2022 |
10.0.15 | 958 | 12/31/2021 |
10.0.14 | 570 | 12/28/2021 |
10.0.7 | 1,489 | 12/22/2021 |
10.0.5 | 755 | 12/18/2021 |
10.0.2 | 653 | 12/14/2021 |
9.9.9 | 1,423 | 11/29/2021 |
9.9.3 | 950 | 11/9/2021 |
9.9.2 | 634 | 11/4/2021 |
9.9.0 | 720 | 10/30/2021 |
9.8.9 | 678 | 10/29/2021 |
9.8.7 | 654 | 10/27/2021 |
9.8.6 | 654 | 10/27/2021 |
9.8.5 | 722 | 10/26/2021 |
9.8.0 | 1,423 | 10/20/2021 |
9.7.9 | 623 | 10/19/2021 |
9.7.5 | 1,517 | 10/14/2021 |
9.7.0 | 875 | 10/9/2021 |
9.6.6 | 1,222 | 8/14/2021 |
9.5.3 | 2,522 | 7/20/2021 |
9.2.0 | 4,315 | 5/26/2021 |
9.1.4 | 1,289 | 4/21/2021 |
9.1.0 | 1,066 | 4/14/2021 |
9.0.0 | 917 | 4/5/2021 |
8.9.9 | 1,043 | 3/30/2021 |
8.9.3 | 1,577 | 3/19/2021 |
8.9.2 | 1,023 | 1/29/2021 |
8.9.1 | 1,018 | 1/24/2021 |
8.9.0 | 1,113 | 1/22/2021 |
8.6.9 | 2,931 | 11/8/2020 |
8.6.6 | 1,981 | 11/2/2020 |
8.6.0 | 4,040 | 10/28/2020 |
8.5.0 | 1,883 | 10/23/2020 |
8.4.0 | 5,611 | 10/13/2020 |
8.3.1 | 2,664 | 10/5/2020 |
8.3.0 | 1,257 | 10/3/2020 |
8.2.2 | 2,055 | 9/26/2020 |
8.2.1 | 1,329 | 9/25/2020 |
8.2.0 | 1,378 | 9/25/2020 |
8.1.19 | 485 | 9/24/2020 |
8.1.18 | 3,283 | 9/21/2020 |
8.1.17 | 4,069 | 9/13/2020 |
8.1.16 | 614 | 9/13/2020 |
8.1.15 | 1,940 | 9/12/2020 |
8.1.11 | 2,497 | 9/11/2020 |
8.1.10 | 1,308 | 9/6/2020 |
8.1.9 | 1,330 | 9/3/2020 |
8.1.8 | 1,314 | 9/2/2020 |
8.1.7 | 1,182 | 8/28/2020 |
8.1.4 | 1,186 | 8/25/2020 |
8.1.3 | 1,315 | 8/18/2020 |
8.1.2 | 1,269 | 8/16/2020 |
8.1.1 | 1,277 | 8/15/2020 |
8.1.0 | 548 | 8/15/2020 |
8.0.1 | 2,683 | 8/7/2020 |
8.0.0 | 1,215 | 8/7/2020 |
7.0.1 | 1,370 | 6/28/2020 |
7.0.0 | 1,337 | 6/28/2020 |
5.0.1 | 2,695 | 5/29/2020 |
5.0.0 | 1,234 | 5/29/2020 |