PostalApiClient 1.0.0
See the version list below for details.
dotnet add package PostalApiClient --version 1.0.0
NuGet\Install-Package PostalApiClient -Version 1.0.0
<PackageReference Include="PostalApiClient" Version="1.0.0" />
<PackageVersion Include="PostalApiClient" Version="1.0.0" />
<PackageReference Include="PostalApiClient" />
paket add PostalApiClient --version 1.0.0
#r "nuget: PostalApiClient, 1.0.0"
#:package PostalApiClient@1.0.0
#addin nuget:?package=PostalApiClient&version=1.0.0
#tool nuget:?package=PostalApiClient&version=1.0.0
PostalApiClient
.NET Core API client for postal mail delivery platform
Available on NuGet
Usage
1. Register PostalClient in startup\builder
// Read configuration from default section "PostalClient"
builder.Services
.AddPostalApiClient(builder.Configuration);
// or set options from action
builder.Services
.AddPostalApiClient(opt =>
{
opt.Server = "http://mypostal.domain";
opt.ApiKey = "Api-Credential-Key";
});
// or read options from custom configuration section
builder.Services
.AddPostalApiClient(builder.Configuration.GetSection("MyCustomSection"));
// or use combination from custom configuration section
// and action for override some options
builder.Services
.AddPostalApiClient(builder.Configuration.GetSection("MyCustomSection"),
options => {
options.ApiKey = "OtherApiKey";
});
// Can use built-in extension methods for setting HttpClient
// e.g. add request handler or logger or retry policy and etc.
builder.Services
.AddPostalApiClient(builder.Configuration)
.AddLogger<CustomHttpLogger>()
.AddHttpMessageHandler<MyRequestHandler>();
2. Get client from DI
// e.g. in controller
public class PostalController : ControllerBase
{
private readonly PostalClient _postalClient;
public PostalController(PostalClient client)
{
_postalClient = client;
}
// ... actions
}
3. Call API methods
var (result, error) = await _postalClient.GetMessageDeliveriesAsync(messageId);
if (error != null)
{
// error handler
}
// continue code with success result
All methods return tuples with two nullable items: Result and Error.
Always check Error for make sure the operation is successful.
Samples
// Send message
var message = new PostalMessage()
{
To = new List<string>
{
"example@example.com",
},
From = "admin@localhost.com",
Subject = "Subject",
PlainBody = "Message body text",
Sender = "Sender email/name",
Tag = "Custom message tag",
ReplyTo = "replyTo@example.com",
Attachments = new List<PostalMessageAttachment>
{
new PostalMessageAttachment()
{
Data = "ContentBse64string",
Name = "Attachment №1",
ContentType = "image/jpeg"
}
},
Headers = new Dictionary<string, string>
{
{"CustomMessageHeader","HeaderValue"}
}
};
var (result, error) = await _postalClient.SendMessageAsync(message);
// Get message details
await _postalClient.GetMessageDetailsAsync(messageId, MessageExpansion.Status | MessageExpansion.PlainBody);
All available methods and description see in official docs or samples in Demo project
4. Webhooks
Create webhook in postal server and add POSTmethod in controller
[HttpPost]
public IActionResult ReceiveWebhook([FromBody] PostalWebhook payload)
{
// ...
// Your webhook handler code
return Ok();
}
PostalWebhook support payload for all events
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net7.0
- Macross.Json.Extensions (>= 3.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- MyCSharp.HttpUserAgentParser (>= 3.0.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on PostalApiClient:
| Package | Downloads |
|---|---|
|
PostalApiClient.Mvc.Extensions
Api client for mail delivery platform Postal. Extenions for MVC |
|
|
RS.EmailSenderPostal
For sending emails using Postal. Builds on PostalApiClient |
GitHub repositories
This package is not used by any popular GitHub repositories.