diff --git a/docs/.obsidian/bookmarks.json b/docs/.obsidian/bookmarks.json new file mode 100644 index 0000000..fc69ce2 --- /dev/null +++ b/docs/.obsidian/bookmarks.json @@ -0,0 +1,3 @@ +{ + "items": [] +} \ No newline at end of file diff --git a/docs/.obsidian/workspace.json b/docs/.obsidian/workspace.json index 28ffdfa..7372b09 100644 --- a/docs/.obsidian/workspace.json +++ b/docs/.obsidian/workspace.json @@ -148,10 +148,10 @@ }, "active": "ae86feaa91c640db", "lastOpenFiles": [ + "emails.md", "index.md", "getting-started.md", "introduction.md", - "storage.md", - "emails.md" + "storage.md" ] } \ No newline at end of file diff --git a/docs/emails.md b/docs/emails.md index 5734a03..4692ebc 100644 --- a/docs/emails.md +++ b/docs/emails.md @@ -37,11 +37,12 @@ Console.WriteLine(sent switch ## Support -| | Link | Tested | -| -------- | ------------------------------------ | ------ | -| Resend | [resend.com](https://resend.com) | yes | -| SendGrid | [sendgrid.com](https://sendgrid.com) | yes | -| Brevo | [brevo.com](https://www.brevo.com/) | yes | +| | Link | Tested | +| -------- | -------------------------------------- | ------ | +| Resend | [resend.com](https://resend.com) | yes | +| SendGrid | [sendgrid.com](https://sendgrid.com) | yes | +| Brevo | [brevo.com](https://www.brevo.com) | yes | +| Mailjet | [mailjet.com](https://www.mailjet.com) | no | ## Inspiration @@ -70,4 +71,4 @@ var email = Html( var html = email.RenderHtml(); var text = email.RenderText(); -``` \ No newline at end of file +``` diff --git a/src/Unator/Emails.cs b/src/Unator/Emails.cs index f412f0c..697cec0 100644 --- a/src/Unator/Emails.cs +++ b/src/Unator/Emails.cs @@ -1,11 +1,37 @@ using System.Collections.Immutable; using System.Net; using System.Net.Http.Headers; -using System.Text.Json; using System.Text; +using System.Text.Json; namespace Unator; +public static class EmailExample +{ + public static async Task Run() + { + var email = new EmailSwitch( + new EmailService(new Resend("resend-api-token"), new DayLimiter(100)), + new EmailService(new Brevo("brevo-api-token"), new DayLimiter(300)), + new EmailService(new SendGrid("send-grid-api-token"), new DayLimiter(100)) + ); + + var sent = await email.Send("romankoshchei@gmail.com", "Roman Koshchei", + to: ["roman@flurium.com"], + subject: "I own Flurium", + text: "Hi me from flurium account!", + html: "

Hi me from flurium account!

" + ); + + Console.WriteLine(sent switch + { + EmailStatus.Success => "Success", + EmailStatus.LimitReached => "Limits are reached", + _ => "Can't send an email" + }); + } +} + public interface ILimiter { /// diff --git a/src/Unator/Preruntime.cs b/src/Unator/Preruntime.cs index fbec933..ab357ee 100644 --- a/src/Unator/Preruntime.cs +++ b/src/Unator/Preruntime.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Text; namespace Unator; diff --git a/src/Web/Program.cs b/src/Web/Program.cs index c3c4383..3596ec7 100644 --- a/src/Web/Program.cs +++ b/src/Web/Program.cs @@ -1,29 +1,5 @@ -using System.Net; -using Unator; -using static Unator.EnvInteresting; +using Unator; //EnvExample.Run(); -var email = new EmailSwitch( - new EmailService(new Resend("resend-api-token"), new DayLimiter(100)), - new EmailService(new Brevo("brevo-api-token"), new DayLimiter(300)), - new EmailService(new SendGrid("send-grid-api-token"), new DayLimiter(100)) -); - -// In future I plan create an email builder -// So it will be easy to create text and html versions at the same time -// For example Header("Hi me from flurium account!") - -var sent = await email.Send("romankoshchei@gmail.com", "Roman Koshchei", - to: ["roman@flurium.com"], - subject: "I own Flurium", - text: "Hi me from flurium account!", - html: "

Hi me from flurium account!

" -); - -Console.WriteLine(sent switch -{ - EmailStatus.Success => "Success", - EmailStatus.LimitReached => "Limits are reached", - _ => "Can't send an email" -}); \ No newline at end of file +await EmailExample.Run(); \ No newline at end of file