magic.lambda.mail
12.0.3
See the version list below for details.
dotnet add package magic.lambda.mail --version 12.0.3
NuGet\Install-Package magic.lambda.mail -Version 12.0.3
<PackageReference Include="magic.lambda.mail" Version="12.0.3" />
paket add magic.lambda.mail --version 12.0.3
#r "nuget: magic.lambda.mail, 12.0.3"
// Install magic.lambda.mail as a Cake Addin #addin nuget:?package=magic.lambda.mail&version=12.0.3 // Install magic.lambda.mail as a Cake Tool #tool nuget:?package=magic.lambda.mail&version=12.0.3
Sending and retrieving emails from Hyperlambda
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
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 multiple 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], [bcc] and [reply-to] 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
You can find an example of how your configuration might look like below if you choose to use configuration settings instead of having to supply server configuration every time you invoke the slot.
{
"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's 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
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 (>= 11.0.5)
- magic.signals.contracts (>= 11.0.5)
- 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 | 377 | 1/22/2024 |
17.1.7 | 164 | 1/12/2024 |
17.1.6 | 141 | 1/11/2024 |
17.1.5 | 150 | 1/5/2024 |
17.0.1 | 191 | 1/1/2024 |
17.0.0 | 327 | 12/14/2023 |
16.11.5 | 294 | 11/12/2023 |
16.9.0 | 304 | 10/9/2023 |
16.7.0 | 516 | 7/11/2023 |
16.4.1 | 361 | 7/2/2023 |
16.4.0 | 347 | 6/22/2023 |
16.3.1 | 296 | 6/7/2023 |
16.3.0 | 306 | 5/28/2023 |
16.1.9 | 600 | 4/30/2023 |
15.10.11 | 453 | 4/13/2023 |
15.9.1 | 566 | 3/27/2023 |
15.9.0 | 453 | 3/24/2023 |
15.8.2 | 487 | 3/20/2023 |
15.7.0 | 362 | 3/6/2023 |
15.5.0 | 1,558 | 1/28/2023 |
15.2.0 | 631 | 1/18/2023 |
15.1.0 | 1,136 | 12/28/2022 |
14.5.7 | 709 | 12/13/2022 |
14.5.5 | 797 | 12/6/2022 |
14.5.1 | 651 | 11/23/2022 |
14.5.0 | 580 | 11/18/2022 |
14.4.5 | 688 | 10/22/2022 |
14.4.1 | 743 | 10/22/2022 |
14.4.0 | 629 | 10/17/2022 |
14.3.1 | 1,247 | 9/12/2022 |
14.3.0 | 635 | 9/10/2022 |
14.1.3 | 899 | 8/7/2022 |
14.1.2 | 676 | 8/7/2022 |
14.1.1 | 638 | 8/7/2022 |
14.0.14 | 676 | 7/26/2022 |
14.0.12 | 644 | 7/24/2022 |
14.0.11 | 640 | 7/23/2022 |
14.0.10 | 644 | 7/23/2022 |
14.0.9 | 624 | 7/23/2022 |
14.0.8 | 719 | 7/17/2022 |
14.0.5 | 779 | 7/11/2022 |
14.0.4 | 741 | 7/6/2022 |
14.0.3 | 696 | 7/2/2022 |
14.0.2 | 659 | 7/2/2022 |
14.0.0 | 846 | 6/25/2022 |
13.4.0 | 2,055 | 5/31/2022 |
13.3.4 | 1,436 | 5/9/2022 |
13.3.0 | 907 | 5/1/2022 |
13.2.0 | 1,138 | 4/21/2022 |
13.1.0 | 1,001 | 4/7/2022 |
13.0.0 | 721 | 4/5/2022 |
12.0.3 | 858 | 3/14/2022 |
11.0.5 | 1,046 | 3/2/2022 |
11.0.4 | 739 | 2/22/2022 |
11.0.3 | 759 | 2/9/2022 |
11.0.2 | 766 | 2/6/2022 |
11.0.1 | 741 | 2/5/2022 |
10.0.21 | 727 | 1/28/2022 |
10.0.20 | 731 | 1/27/2022 |
10.0.19 | 733 | 1/23/2022 |
10.0.18 | 720 | 1/17/2022 |
10.0.15 | 920 | 12/31/2021 |
10.0.14 | 541 | 12/28/2021 |
10.0.7 | 1,442 | 12/22/2021 |
10.0.5 | 730 | 12/18/2021 |
10.0.2 | 621 | 12/14/2021 |
9.9.9 | 1,392 | 11/29/2021 |
9.9.3 | 910 | 11/9/2021 |
9.9.2 | 602 | 11/4/2021 |
9.9.0 | 699 | 10/30/2021 |
9.8.9 | 667 | 10/29/2021 |
9.8.7 | 631 | 10/27/2021 |
9.8.6 | 624 | 10/27/2021 |
9.8.5 | 699 | 10/26/2021 |
9.8.0 | 1,380 | 10/20/2021 |
9.7.9 | 595 | 10/19/2021 |
9.7.5 | 1,469 | 10/14/2021 |
9.7.0 | 848 | 10/9/2021 |
9.6.6 | 1,175 | 8/14/2021 |
9.5.3 | 2,458 | 7/20/2021 |
9.2.0 | 4,229 | 5/26/2021 |
9.1.4 | 1,255 | 4/21/2021 |
9.1.0 | 1,033 | 4/14/2021 |
9.0.0 | 881 | 4/5/2021 |
8.9.9 | 1,016 | 3/30/2021 |
8.9.3 | 1,545 | 3/19/2021 |
8.9.2 | 1,007 | 1/29/2021 |
8.9.1 | 1,010 | 1/24/2021 |
8.9.0 | 1,102 | 1/22/2021 |
8.6.9 | 2,906 | 11/8/2020 |
8.6.6 | 1,960 | 11/2/2020 |
8.6.0 | 3,993 | 10/28/2020 |
8.5.0 | 1,845 | 10/23/2020 |
8.4.0 | 5,542 | 10/13/2020 |
8.3.1 | 2,635 | 10/5/2020 |
8.3.0 | 1,227 | 10/3/2020 |
8.2.2 | 2,014 | 9/26/2020 |
8.2.1 | 1,306 | 9/25/2020 |
8.2.0 | 1,349 | 9/25/2020 |
8.1.19 | 468 | 9/24/2020 |
8.1.18 | 3,253 | 9/21/2020 |
8.1.17 | 4,033 | 9/13/2020 |
8.1.16 | 595 | 9/13/2020 |
8.1.15 | 1,897 | 9/12/2020 |
8.1.11 | 2,462 | 9/11/2020 |
8.1.10 | 1,270 | 9/6/2020 |
8.1.9 | 1,303 | 9/3/2020 |
8.1.8 | 1,305 | 9/2/2020 |
8.1.7 | 1,158 | 8/28/2020 |
8.1.4 | 1,158 | 8/25/2020 |
8.1.3 | 1,288 | 8/18/2020 |
8.1.2 | 1,234 | 8/16/2020 |
8.1.1 | 1,243 | 8/15/2020 |
8.1.0 | 543 | 8/15/2020 |
8.0.1 | 2,641 | 8/7/2020 |
8.0.0 | 1,193 | 8/7/2020 |
7.0.1 | 1,353 | 6/28/2020 |
7.0.0 | 1,295 | 6/28/2020 |
5.0.1 | 2,653 | 5/29/2020 |
5.0.0 | 1,217 | 5/29/2020 |