magic.lambda.mail 10.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package magic.lambda.mail --version 10.0.5
NuGet\Install-Package magic.lambda.mail -Version 10.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="magic.lambda.mail" Version="10.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.lambda.mail --version 10.0.5
#r "nuget: magic.lambda.mail, 10.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install magic.lambda.mail as a Cake Addin
#addin nuget:?package=magic.lambda.mail&version=10.0.5

// Install magic.lambda.mail as a Cake Tool
#tool nuget:?package=magic.lambda.mail&version=10.0.5

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

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 263 1/22/2024
17.1.7 145 1/12/2024
17.1.6 119 1/11/2024
17.1.5 127 1/5/2024
17.0.1 165 1/1/2024
17.0.0 311 12/14/2023
16.11.5 275 11/12/2023
16.9.0 287 10/9/2023
16.7.0 495 7/11/2023
16.4.1 351 7/2/2023
16.4.0 335 6/22/2023
16.3.1 284 6/7/2023
16.3.0 294 5/28/2023
16.1.9 583 4/30/2023
15.10.11 436 4/13/2023
15.9.1 558 3/27/2023
15.9.0 438 3/24/2023
15.8.2 472 3/20/2023
15.7.0 351 3/6/2023
15.5.0 1,534 1/28/2023
15.2.0 615 1/18/2023
15.1.0 1,121 12/28/2022
14.5.7 690 12/13/2022
14.5.5 780 12/6/2022
14.5.1 633 11/23/2022
14.5.0 566 11/18/2022
14.4.5 671 10/22/2022
14.4.1 728 10/22/2022
14.4.0 620 10/17/2022
14.3.1 1,229 9/12/2022
14.3.0 629 9/10/2022
14.1.3 890 8/7/2022
14.1.2 668 8/7/2022
14.1.1 628 8/7/2022
14.0.14 660 7/26/2022
14.0.12 636 7/24/2022
14.0.11 627 7/23/2022
14.0.10 635 7/23/2022
14.0.9 616 7/23/2022
14.0.8 705 7/17/2022
14.0.5 763 7/11/2022
14.0.4 734 7/6/2022
14.0.3 683 7/2/2022
14.0.2 646 7/2/2022
14.0.0 838 6/25/2022
13.4.0 2,039 5/31/2022
13.3.4 1,429 5/9/2022
13.3.0 901 5/1/2022
13.2.0 1,131 4/21/2022
13.1.0 994 4/7/2022
13.0.0 707 4/5/2022
12.0.3 847 3/14/2022
11.0.5 1,032 3/2/2022
11.0.4 725 2/22/2022
11.0.3 750 2/9/2022
11.0.2 754 2/6/2022
11.0.1 730 2/5/2022
10.0.21 714 1/28/2022
10.0.20 723 1/27/2022
10.0.19 725 1/23/2022
10.0.18 715 1/17/2022
10.0.15 911 12/31/2021
10.0.14 536 12/28/2021
10.0.7 1,431 12/22/2021
10.0.5 725 12/18/2021
10.0.2 616 12/14/2021
9.9.9 1,380 11/29/2021
9.9.3 902 11/9/2021
9.9.2 597 11/4/2021
9.9.0 693 10/30/2021
9.8.9 658 10/29/2021
9.8.7 621 10/27/2021
9.8.6 610 10/27/2021
9.8.5 692 10/26/2021
9.8.0 1,367 10/20/2021
9.7.9 586 10/19/2021
9.7.5 1,460 10/14/2021
9.7.0 836 10/9/2021
9.6.6 1,168 8/14/2021
9.5.3 2,444 7/20/2021
9.2.0 4,219 5/26/2021
9.1.4 1,241 4/21/2021
9.1.0 1,018 4/14/2021
9.0.0 874 4/5/2021
8.9.9 1,004 3/30/2021
8.9.3 1,536 3/19/2021
8.9.2 1,000 1/29/2021
8.9.1 999 1/24/2021
8.9.0 1,090 1/22/2021
8.6.9 2,894 11/8/2020
8.6.6 1,952 11/2/2020
8.6.0 3,973 10/28/2020
8.5.0 1,837 10/23/2020
8.4.0 5,530 10/13/2020
8.3.1 2,617 10/5/2020
8.3.0 1,219 10/3/2020
8.2.2 2,006 9/26/2020
8.2.1 1,299 9/25/2020
8.2.0 1,337 9/25/2020
8.1.19 460 9/24/2020
8.1.18 3,245 9/21/2020
8.1.17 4,017 9/13/2020
8.1.16 584 9/13/2020
8.1.15 1,886 9/12/2020
8.1.11 2,451 9/11/2020
8.1.10 1,260 9/6/2020
8.1.9 1,295 9/3/2020
8.1.8 1,296 9/2/2020
8.1.7 1,148 8/28/2020
8.1.4 1,150 8/25/2020
8.1.3 1,279 8/18/2020
8.1.2 1,226 8/16/2020
8.1.1 1,234 8/15/2020
8.1.0 537 8/15/2020
8.0.1 2,631 8/7/2020
8.0.0 1,182 8/7/2020
7.0.1 1,334 6/28/2020
7.0.0 1,285 6/28/2020
5.0.1 2,635 5/29/2020
5.0.0 1,208 5/29/2020