-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff96697
commit 176cf6f
Showing
1 changed file
with
41 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,34 +41,49 @@ dotnet add package FlexiMail | |
|
||
## Usage | ||
|
||
To use FlexiMail, follow the steps below: | ||
To use **FlexiMail**, follow the steps below: | ||
|
||
### Basic Example | ||
|
||
```csharp | ||
using FlexiMail; | ||
using FlexiMail.Models.Configurations; | ||
using FlexiMail.Models.Foundations.Bodies; | ||
using FlexiMail.Models.Foundations.Messages; | ||
public class EmailService | ||
namespace FlexiMail.Sample | ||
{ | ||
private readonly IFlexiMailClient flexiMailClient; | ||
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" | ||
}; | ||
public EmailService(IFlexiMailClient flexiMailClient) => | ||
this.flexiMailClient = flexiMailClient; | ||
var flexiMailClient = new FlexiMailClient(configurations); | ||
public async Task SendWelcomeEmail(string recipientEmail) | ||
{ | ||
var flexiMessage = new FlexiMessage() | ||
var nessage = new FlexiMessage | ||
{ | ||
Subject = "FlexiMail is a cool library", | ||
To = [recipientEmail], | ||
To = ["[email protected]"], | ||
Cc = ["[email protected]"], | ||
Subject = "Keep testing FlexiMail", | ||
Body = new FlexiBody | ||
{ | ||
Content = "<h3>Welcome to FlexiMail</h3><p>Bonjour tout le monde!</p>", | ||
ContentType = BodyContentType.Html | ||
Content = "This is the message body. It can be a plain text or HTML.", | ||
ContentType = BodyContentType.PlainText | ||
} | ||
}; | ||
await this.flexiMailClient.SendAndSaveCopyAsync(flexiMessage); | ||
await flexiMailClient.SendAndSaveCopyAsync(nessage); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} | ||
``` | ||
|
@@ -80,20 +95,18 @@ configuration file: | |
```json | ||
{ | ||
"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": [ | ||
"scope1", | ||
"scope2", | ||
"scope3" | ||
] | ||
} | ||
"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" | ||
] | ||
} | ||
} | ||
``` | ||
|
@@ -113,21 +126,6 @@ to [The-Standard](https://github.com/hassanhabib/The-Standard): | |
The main class, `FlexiMailClient`, implements the `IFlexiMailClient` interface and serves as the entry point for most | ||
operations. | ||
## Testing | ||
Unit tests are provided to ensure the reliability of the **FlexiMail** library. The tests are located in the | ||
`FlexiMail.Tests.Unit` and `FlexiMail.Test.Integration` projects. | ||
### Running Tests | ||
To run the tests, use the following command in the terminal: | ||
```bash | ||
dotnet test | ||
``` | ||
Ensure that all dependencies are restored before running the tests. | ||
## Contributing | ||
Contributions to **FlexiMail** are welcome! Please follow these steps to contribute: | ||
|