FlexiMail is a flexible email client library designed to integrate seamlessly into your .NET applications. It provides an easy-to-use interface for sending emails and managing various email-related tasks.
- Easy Integration: Seamlessly integrate FlexiMail into your .NET projects.
- Multiple Email Providers: Support for multiple email service providers. [Call for contribution]
- Asynchronous Operations: Perform email sending and processing asynchronously.
- Testable Components: Easily write unit and integration tests for your email functionality.
You can install FlexiMail via NuGet or by adding the project to your solution manually.
To install FlexiMail using NuGet, run the following command in the NuGet Package Manager Console:
Install-Package FlexiMail
Or, you can find the package on NuGet.
To install FlexiMail using the .NET CLI, use the following command:
dotnet add package FlexiMail
-
Clone the repository:
git clone https://github.com/mabroukmahdhi/FlexiMail
-
Add the
FlexiMail
project to your solution. -
Reference the
FlexiMail
project in your main application project.
To use FlexiMail, follow the steps below:
using FlexiMail.Models.Configurations;
using FlexiMail.Models.Foundations.Bodies;
using FlexiMail.Models.Foundations.Messages;
namespace FlexiMail.Sample
{
class Program
{
static async Task Main(string[] args)
{
var configurations = new ExchangeConfigurations
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
TenantId = "your-tenant-id",
Authority = "https://login.microsoftonline.com/{your-tenant-id}",
Scopes = ["https://outlook.office365.com/.default"],
SmtpAddress = "your-sender-email"
};
var flexiMailClient = new FlexiMailClient(configurations);
var nessage = new FlexiMessage
{
To = ["email@domain.com"],
Cc = ["other-email@domain.com"],
Subject = "Keep testing FlexiMail",
Body = new FlexiBody
{
Content = "This is the message body. It can be a plain text or HTML.",
ContentType = BodyContentType.PlainText
}
};
await flexiMailClient.SendAndSaveCopyAsync(nessage);
Console.ReadKey();
}
}
}
FlexiMail can be configured to use different email service providers. Configure the desired provider in your app's configuration file:
{
"ExchangeConfigurations": {
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret",
"TenantId": "your-tenant-id",
"SmtpAddress": "your-smtp-address",
"Sid": "your-sid",
"PrincipalName": "your-principal-name",
"Authority": "your-authority",
"Scopes": [
"https://outlook.office365.com/.default"
]
}
}
Note: You can use SmtpAddress
, Sid
or PrincipalName
in order to configure your exchange service.
FlexiMail is organized into the following components according to The-Standard:
- Brokers: Handle communication with external email services.
- Models: Contain the data structures used across the library.
- Services: Core logic for sending and managing emails.
- Extensions: Helper methods and extensions for common tasks.
The main class, FlexiMailClient
, implements the IFlexiMailClient
interface and serves as the entry point for most
operations.
Contributions to FlexiMail are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b users/your-github-id/YourFeature
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin users/your-github-id/YourFeature
). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
For more information or questions, feel free to contact me at contact@mahdhi.com.