Lefty.Email
0.1.2
dotnet tool install --global Lefty.Email --version 0.1.2
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local Lefty.Email --version 0.1.2
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Lefty.Email&version=0.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package Lefty.Email --version 0.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
lemail
.NET tool to send emails through SMTP, or Resend.
Installing
To install the tool as a repository tool, run the following command in the root of your repository:
> dotnet tool install --local Lefty.Email --create-manifest-if-needed
If you'd rather have the tool installed globally in your machine, run the following command:
> dotnet tool install --global Lefty.Email
Senders
When using smtp sender (default):
| Env | M/O | Default | Description |
|---|---|---|---|
SMTP_HOST |
Mandatory | none | Hostname or IP address of SMTP server |
SMTP_PORT |
Optional | 587 |
Port number |
SMTP_SSL |
Optional | True |
Whether to use SSL |
SMTP_USERNAME |
Optional | null | Username for authentication |
SMTP_PASSWORD |
Required if username specified | null | Password |
When using resend sender:
| Env | M/O | Default | Description |
|---|---|---|---|
RESEND_APITOKEN |
Mandatory | none | API token, as obtained from dashboard |
> set EMAIL_SENDER=resend
> set RESEND_APITOKEN=<api>
Example
The tool accepts a single argument, which is the name of a Json file.
> cat email.json
{
"from": "Master Yoda <yoda@dagobah.sw>",
"to": "Luke Skywalker <lskywalker19@tatooine.sw>",
"subject": "Reminder",
"htmlBody": "<h1>Use the force</h1>"
}
> dotnet lemail email.json
It is also possible to pipe JSON to the command:
> cat email.json | dotnet lemail --stdin
Usage patterns
The tool supports all of the following usage patterns to construct the email message to send:
- JSON (file, or piped in)
- Environment variables, only if
--envis provided) - CLI options
Json format
The format of the file is as follows:
| Property | Type | M/O | Description |
|---|---|---|---|
from |
Mandatory | Email sender | |
to |
Email, or Array of Emails | Mandatory | Email recipients |
cc |
Email, or Array of Emails | Optional | Additional email recipients |
bcc |
Email, or Array of Emails | Optional | Non-disclosed email recipients |
subject |
String | Mandatory | Subject of email message |
textBody |
String, or @Filename | Mandatory | Plain-text body |
htmlBody |
String, or @Filename | Mandatory | HTML body |
An Email can be expressed as follows:
lskywalker19@tatooine.sw- Just the e-email addressLuke Skywalker <lskywalker19@tatooine.sw>- With display name
Environment variables
The following variables will be evaluated, but only if --env option
is provided in the command line.
| Env | Type | Description |
|---|---|---|
EMAIL_FROM |
Sender email address | |
EMAIL_TO |
Emails | Semi colon seperated list of recipients |
EMAIL_SUBJECT |
String | Subject |
EMAIL_HTML |
File | File name of HTML body |
EMAIL_TEXT |
File | File name of text body |
CLI options
> dotnet lemail --help
Email sender
Usage: lemail [options] <InputFile>
Arguments:
InputFile Input JSON file
Options:
--version Show version information.
-f|--from Sender email address
-t|--to Recipient email address
-s|--subject Subject
-h|--html-file HTML file
-x|--text-file Text file
-X|--text Text content
--stdin Read JSON from stdin
-e|--env Load sender/recipient from environment variables
-?|--help Show help information
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.