CommunityAbp.AspNetZero.Emailing.Postmark 1.0.2

dotnet add package CommunityAbp.AspNetZero.Emailing.Postmark --version 1.0.2
                    
NuGet\Install-Package CommunityAbp.AspNetZero.Emailing.Postmark -Version 1.0.2
                    
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="CommunityAbp.AspNetZero.Emailing.Postmark" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CommunityAbp.AspNetZero.Emailing.Postmark" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="CommunityAbp.AspNetZero.Emailing.Postmark" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CommunityAbp.AspNetZero.Emailing.Postmark --version 1.0.2
                    
#r "nuget: CommunityAbp.AspNetZero.Emailing.Postmark, 1.0.2"
                    
#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.
#addin nuget:?package=CommunityAbp.AspNetZero.Emailing.Postmark&version=1.0.2
                    
Install CommunityAbp.AspNetZero.Emailing.Postmark as a Cake Addin
#tool nuget:?package=CommunityAbp.AspNetZero.Emailing.Postmark&version=1.0.2
                    
Install CommunityAbp.AspNetZero.Emailing.Postmark as a Cake Tool

CommunityAbp.AspNetZero.Emailing.Postmark

A seamless integration module that enables Postmark email delivery services for AspNetZero and ABP Framework applications.

Overview

This package provides a robust implementation of email-sending capabilities using Postmark's API within the AspNetZero and ABP Framework ecosystem. It extends the default emailing system (MailKit) with Postmark's powerful features while maintaining the simplicity and flexibility of ABP's modular architecture.

Features

  • Drop-in replacement for ABP's default email sender
  • Full support for Postmark's transactional email API
  • Template management and synchronization
  • Email tracking and analytics integration
  • Comprehensive logging and monitoring
  • Automatic retry handling for failed deliveries
  • Support for both synchronous and asynchronous sending
  • Batch email processing capabilities

Installation

dotnet add package CommunityAbp.AspNetZero.Emailing.Postmark

Quick Start

  1. Install the package
  2. Configure your Postmark API credentials in appsettings.json
  3. Register the module in your application
  4. Start sending emails using Postmark's infrastructure

Configuration

{
  "Postmark": {
    "ApiKey": "your-api-key",
    "FromAddress": "sender@yourdomain.com"
  }
}

Features

Email Sending

  • Basic email sending support
  • HTML and plain text email bodies
  • Multiple recipients (To, CC, BCC)
  • Custom From address support
  • Default From address fallback from configuration
  • Custom headers

Postmark Feature Support

  • Postmark template integration
  • Template ID support (numeric identifier)
  • Template alias support (string identifier)
  • Dynamic template model binding
  • JSON serialization of template models
  • Email open tracking
  • Click tracking
  • Tag support

Attachments

  • File attachment support
  • Multiple attachments per email
  • Content-type detection
  • Base64 encoding handling
  • Stream position handling

Configuration & Setup

  • Easy module integration with AbpModule
  • Automatic dependency injection setup
  • Configurable API key
  • Configurable sender email
  • Custom PostmarkClient configuration support

Logging & Diagnostics

  • Structured logging throughout
  • Debug level operational logs
  • Information level success logs
  • Error level failure logs
  • Attachment processing logs
  • Template usage logs
  • Message ID tracking

Framework Support

  • .NET Standard 2.0 support
  • .NET Standard 2.1 support
  • .NET 8.0 support

Developer Experience

  • Fluent API for template usage
  • Extension methods for common operations
  • Clear exception messages
  • Consistent with ABP patterns
  • Minimal configuration required

Not Yet Implemented

  • Batch email sending
  • Bounce handling
  • Webhook support
  • Message stream support
  • Server-level configuration
  • Retry policies

Postmark Templates

Template Identification

  • Postmark supports two ways to identify templates:
    • TemplateId: A numeric identifier (e.g., 1234567)
    • TemplateAlias: A string identifier (e.g., "welcome-email")
  • These are stored in the mail headers using custom X-headers:
mail.Headers["X-Postmark-Template-Id"] = "1234567";
// OR
mail.Headers["X-Postmark-Template-Alias"] = "welcome-email";

Template Model

  • The template model contains the variables that will be merged into your template
  • It's stored as JSON in the mail body
  • Example template model:
{
  "userName": "John Doe",
  "confirmationLink": "https://example.com/confirm/123",
  "expiryDate": "2024-02-01"
}

Full Template Example

// Example 1: Using Template ID
var mail = new MailMessage();
mail.To.Add("user@example.com");
mail.UseTemplate(1234567, new { 
    userName = "John Doe",
    confirmationLink = "https://example.com/confirm/123"
});

// Example 2: Using Template Alias
var mail = new MailMessage();
mail.To.Add("user@example.com");
mail.UseTemplate("welcome-email", new { 
    userName = "John Doe",
    confirmationLink = "https://example.com/confirm/123"
});

Attachments

Here's an example of how to send attachments:

var mail = new MailMessage();
mail.To.Add("recipient@example.com");
mail.Subject = "Test with attachment";

// Adding a file attachment
mail.Attachments.Add(new Attachment("document.pdf", "application/pdf"));

// For templated emails with attachments
mail.UseTemplate("welcome-email", new { UserName = "John" });

await _emailSender.SendEmailAsync(mail);

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Before submitting any changes, make sure to read our contribution guidelines.

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 is compatible.  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. 
.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 is compatible. 
.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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 81 1/24/2025
1.0.1 90 1/23/2025
1.0.0 81 1/23/2025