Eaf.MailKit
9.4.6
Prefix Reserved
dotnet add package Eaf.MailKit --version 9.4.6
NuGet\Install-Package Eaf.MailKit -Version 9.4.6
<PackageReference Include="Eaf.MailKit" Version="9.4.6" />
<PackageVersion Include="Eaf.MailKit" Version="9.4.6" />
<PackageReference Include="Eaf.MailKit" />
paket add Eaf.MailKit --version 9.4.6
#r "nuget: Eaf.MailKit, 9.4.6"
#:package Eaf.MailKit@9.4.6
#addin nuget:?package=Eaf.MailKit&version=9.4.6
#tool nuget:?package=Eaf.MailKit&version=9.4.6
Eaf.MailKit
Módulo EAF para envio de e-mails baseado em MailKit, estendendo as abstrações Abp.MailKit com retry, templates e configurações específicas do EAF.
Funcionalidades
- Envio de e-mails via
IEmailSender(MailKit). - Retry automático em falhas transitórias do SMTP (até 3 tentativas com backoff exponencial).
- Templates de e-mail com placeholders
{{Nome}}e fallback por tenant. - Configurações de certificado SSL/TLS e validação desabilitada para desenvolvimento.
- Spans do
ActivitySource"Eaf.MailKit" para observabilidade (OpenTelemetry).
Instalação
Adicione a dependência ao módulo ABP:
[DependsOn(typeof(EafMailKitModule))]
public class MyProjectModule : AbpModule
{
}
Configuração
As configurações podem ser definidas via ISettingManager ou injetando EafMailKitConfiguration:
| Setting | Padrão | Descrição |
|---|---|---|
Eaf.MailKit.RetryCount |
3 |
Número máximo de tentativas. |
Eaf.MailKit.RetryDelayMilliseconds |
500 |
Tempo base entre tentativas (ms). |
Eaf.MailKit.DisableCertificateValidation |
false |
Desabilita validação do certificado SMTP. |
Configure as credenciais SMTP padrão do ABP (Abp.Net.Mail.EmailSettingNames.Smtp.Host, Port, UserName, Password etc.).
Uso
public class MyService
{
private readonly IEmailSender _emailSender;
private readonly IEmailTemplateManager _templateManager;
public MyService(IEmailSender emailSender, IEmailTemplateManager templateManager)
{
_emailSender = emailSender;
_templateManager = templateManager;
}
public async Task SendWelcomeEmail(string email, string name)
{
var body = await _templateManager.RenderAsync("Welcome", new { Name = name });
await _emailSender.SendAsync(email, "Bem-vindo", body, isBodyHtml: true);
}
}
Templates
Armazene templates em memória (padrão) ou substitua IEmailTemplateStore por uma implementação que use banco de dados:
var store = Resolve<IEmailTemplateStore>();
O formato dos placeholders é {{Propriedade}}. Propriedades ausentes são substituídas por vazio.
E-mail com anexos
using var message = new MailMessage("from@example.com", "to@example.com", "Subject", "<h1>Body</h1>")
{
IsBodyHtml = true
};
message.Attachments.Add(new Attachment("caminho/para/arquivo.pdf"));
await _emailSender.SendAsync(message);
Eaf.MailKit (English)
EAF module for email sending based on MailKit, extending Abp.MailKit abstractions with retry, templates, and EAF-specific configuration.
Features
- Email sending via
IEmailSender(MailKit). - Automatic retry on transient SMTP failures (up to 3 attempts with exponential backoff).
- Email templates with
{{Name}}placeholders and tenant fallback. - SSL/TLS and certificate validation settings.
ActivitySource"Eaf.MailKit" spans for observability (OpenTelemetry).
Configuration
| Setting | Default | Description |
|---|---|---|
Eaf.MailKit.RetryCount |
3 |
Maximum retry attempts. |
Eaf.MailKit.RetryDelayMilliseconds |
500 |
Base delay between retries (ms). |
Eaf.MailKit.DisableCertificateValidation |
false |
Disables SMTP certificate validation. |
Also configure ABP SMTP settings (Abp.Net.Mail.EmailSettingNames.Smtp.*).
| 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. |
-
net10.0
- Abp (>= 10.5.0)
- Abp.MailKit (>= 10.5.0)
- MailKit (>= 4.16.0)
- MessagePack (>= 2.5.301)
- MimeKit (>= 4.16.0)
- System.Security.Cryptography.Xml (>= 10.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.