EasyMailSender 1.0.0

dotnet add package EasyMailSender --version 1.0.0
                    
NuGet\Install-Package EasyMailSender -Version 1.0.0
                    
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="EasyMailSender" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyMailSender" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EasyMailSender" />
                    
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 EasyMailSender --version 1.0.0
                    
#r "nuget: EasyMailSender, 1.0.0"
                    
#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.
#:package EasyMailSender@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EasyMailSender&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=EasyMailSender&version=1.0.0
                    
Install as a Cake Tool

EasyMailSender

EasyMailSender, .NET uygulamalarında e-posta gönderme işlemlerini kolaylaştıran basit ve kullanımı kolay bir kütüphanedir.

Özellikler

  • .NET 8.0 için tam destek
  • .NET Core/ASP.NET Core uygulamalarında kolay entegrasyon
  • Dependency Injection desteği
  • HTML içerikli e-postalar
  • Dosyadan e-posta içeriği okuma
  • SSL/TLS destekli SMTP yapılandırması
  • Birden fazla alıcıya e-posta gönderme
  • CC ve BCC desteği

Kurulum

Git üzerinden releases kısmından en güncel nupkg dosyasını nuget package sourceu offline ayarlayarak kurabilirsiniz.

<a href="https://github.com/baris-taner-one/EasyMailSender/releases/download/1.0.0/EasyMailSender.1.0.0.nupkg">Tıklayarak 1.0.0 sürümünü indirebilirsin</a>

Gereksinimler

  • .NET 8.0 veya daha yeni sürüm

Hızlı Başlangıç

Daha ayrıntılı bilgi ve örnekler için KULLANIM_KILAVUZU.md dosyasını inceleyebilirsiniz.

1. appsettings.json Yapılandırması

appsettings.json dosyanızda e-posta ayarlarını aşağıdaki şekilde yapılandırın:

{
  "EmailSettings": {
    "SmtpServer": "smtp.example.com",
    "Port": 587,
    "EnableSsl": true,
    "UserName": "your-email@example.com",
    "Password": "your-password",
    "FromAddress": "your-email@example.com",
    "FromName": "Your Name"
  }
}

2. Servis Kaydı

Program.cs dosyanızda servisi kaydedin:

using EasyMailSender.Extensions;

// ASP.NET Core uygulamasında:
builder.Services.AddEasyMailSender(builder.Configuration);

// VEYA Console/Worker uygulamasında:
var host = Host.CreateDefaultBuilder(args)
    .ConfigureServices((context, services) =>
    {
        services.AddEasyMailSender(context.Configuration);
    })
    .Build();

3. Temel Kullanım

using EasyMailSender.Models;
using EasyMailSender.Services.MailSend;

// IMailSender servisini DI container'dan alın
private readonly IMailSender _mailSender;

public YourClass(IMailSender mailSender)
{
    _mailSender = mailSender;
}

// E-posta gönderme işlemi
public async Task SendEmailExample()
{
    try
    {
        await _mailSender.SendMailAsync(new MailMessageModel
        {
            To = "recipient@example.com",
            Subject = "Test E-postası",
            Body = "<h1>Merhaba!</h1><p>Bu bir test e-postasıdır.</p>",
            IsHtml = true
        });
        
        Console.WriteLine("E-posta başarıyla gönderildi.");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"E-posta gönderimi sırasında hata oluştu: {ex.Message}");
    }
}

4. Çoklu Alıcı, CC ve BCC Kullanımı

// Birden fazla alıcıya ve CC'ye e-posta gönderme
await _mailSender.SendMailAsync(new MailMessageModel
{
    To = "main-recipient@example.com", // Ana alıcı
    
    // Birden fazla ek alıcı
    ToList = new List<string>
    {
        "recipient1@example.com",
        "recipient2@example.com"
    },
    
    // CC - Karbon Kopya alıcıları
    Cc = new List<string>
    {
        "manager@example.com",
        "supervisor@example.com"
    },
    
    // BCC - Gizli Karbon Kopya alıcıları
    Bcc = new List<string>
    {
        "archive@example.com"
    },
    
    Subject = "Önemli Duyuru",
    Body = "<h1>Toplantı Hatırlatması</h1><p>Yarın saat 14:00'de toplantımız olacaktır.</p>",
    IsHtml = true
});

MailMessageModel Parametreleri

Parametre Tür Açıklama
To string Birincil alıcı e-posta adresi
ToList List<string> Birden fazla alıcı e-posta adresi
Cc List<string> CC (Karbon Kopya) alıcıları
Bcc List<string> BCC (Gizli Karbon Kopya) alıcıları
Subject string E-posta konusu
Body string E-posta içeriği
BodyFilePath string E-posta içeriğinin okunacağı dosya yolu (varsa)
IsHtml bool İçeriğin HTML formatında olup olmadığı

Farklı Proje Türlerinde Kullanım

Farklı .NET 8 proje türlerinde EasyMailSender'ı nasıl kullanacağınıza dair detaylı örnekler için KULLANIM_KILAVUZU.md dosyasını inceleyin:

  • ASP.NET Core Minimal API
  • ASP.NET Core MVC
  • Worker Service
  • Console Uygulaması
  • Blazor Server
  • Web API
  • Çoklu alıcı ve CC kullanımı örnekleri

Hata Yönetimi

E-posta gönderimi sırasında aşağıdaki hata türlerini ele almanız gerekebilir:

  • SmtpException: SMTP sunucusuyla ilgili hatalar
  • FileNotFoundException: BodyFilePath belirtildiğinde, dosya bulunamazsa
  • Exception: Diğer beklenmeyen hatalar

Sorun Giderme

Yaygın Hatalar

  1. "Syntax error, command unrecognized":

    • SMTP kimlik doğrulama ayarlarını kontrol edin
    • Kullanıcı adı (UserName) ve şifre (Password) değerlerinin doğru olduğunu kontrol edin
  2. SSL/TLS Hataları:

    • EnableSsl ayarının doğru yapılandırıldığından emin olun
    • SMTP sunucunuz için doğru portu kullandığınızdan emin olun (genellikle 587 veya 465)
  3. Kimlik Doğrulama Hataları:

    • SMTP sunucusunun kimlik doğrulamasını desteklediğinden emin olun
    • Kullanıcı adı ve şifrenin doğru olduğunu kontrol edin
Product Compatible and additional computed target framework versions.
.NET 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.  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. 
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.0 176 9/2/2025