-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from geeklearningio/release/0.5.0
Release/0.5.0
- Loading branch information
Showing
39 changed files
with
433 additions
and
554 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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="GL Unstable" value="https://www.myget.org/F/gl-unstable/api/v3/index.json" /> | ||
</packageSources> | ||
</configuration> |
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 |
---|---|---|
@@ -1,9 +1,133 @@ | ||
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/GeekLearning.Email.svg?maxAge=2592000&label=GeekLearning.Email)](https://www.nuget.org/packages/GeekLearning.Email) | ||
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/GeekLearning.Email.InMemory.svg?maxAge=2592000&label=GeekLearning.Email.InMemory)](https://www.nuget.org/packages/GeekLearning.Email.InMemory) | ||
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/GeekLearning.Email.SendGrid.svg?maxAge=2592000&label=GeekLearning.Email.SendGrid)](https://www.nuget.org/packages/GeekLearning.Email.SendGrid) | ||
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/GeekLearning.Email.Smtp.svg?maxAge=2592000&label=GeekLearning.Email.Smtp)](https://www.nuget.org/packages/GeekLearning.Email.Smtp) | ||
[![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Email.svg?style=flat-square&label=NuGet)](https://www.nuget.org/packages/GeekLearning.Email/) | ||
[![Build Status](https://geeklearning.visualstudio.com/_apis/public/build/definitions/f841b266-7595-4d01-9ee1-4864cf65aa73/28/badge)](#) | ||
|
||
# gl-dotnet-email | ||
|
||
Coming Soon ! | ||
GeekLearning.Email provide an abstraction over various email providers. It brings builtin templates | ||
support thanks to our [templating library](https://github.com/geeklearningio/gl-dotnet-templating). | ||
It also bring email interception support so you can easily redirect email to developers/tester | ||
inboxes in developement environement. | ||
|
||
## Getting Started | ||
|
||
|
||
In your project.json add required dependencies : | ||
``` | ||
"GeekLearning.Storage.FileSystem": "0.6.0-*", | ||
"GeekLearning.Templating.Handlebars": "0.5.0-*", | ||
"GeekLearning.Email": "0.5.0-*", | ||
"GeekLearning.Email.Smtp": ""0.5.0-*" | ||
``` | ||
|
||
Then add required settings in your `appsettings.json` file. | ||
|
||
In this example, we will use FileSystem provider to configure a storage provider which will load files from | ||
a `Templates` folder relative to Application Root. This could be configured to use | ||
an Azure Container instead (see storage documentation). | ||
|
||
We will configure `Email` to use the `Smtp` provider. If any Mockup Recipients are defined, they will | ||
receive the email in place of the original Recipients. | ||
|
||
```json | ||
"Email": { | ||
"Provider": { | ||
"Type": "Smtp", | ||
"Parameters": { | ||
"Host": "127.0.0.1", | ||
"Port": "25", | ||
"UserName": "", | ||
"Password": "" | ||
}, | ||
}, | ||
"DefaultSender": { | ||
"Email": "[email protected]", | ||
"DisplayName": "Your Company Name" | ||
}, | ||
"TemplateStorage": "Templates", | ||
"Mockup": { | ||
"Recipients": [], | ||
"Exceptions": { | ||
"Emails": [], | ||
"Domains": [] | ||
} | ||
} | ||
}, | ||
"Storage": { | ||
"Stores": { | ||
"Templates": { | ||
"Provider": "FileSystem", | ||
"Parameters": { | ||
"Path": "Templates" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Then in your `Startup.cs` file add required dependencies and configuration to the DI container. | ||
|
||
```csharp | ||
services.AddStorage().AddFileSystemStorage(this.HostingEnvironment.ContentRootPath); | ||
services.Configure<StorageOptions>(Configuration.GetSection("Storage")); | ||
services.AddTemplating().AddHandlebars(); | ||
|
||
services.AddEmail() | ||
.AddSmtpEmail(); | ||
services.Configure<EmailOptions>(Configuration.GetSection("Email")); | ||
``` | ||
|
||
Then we will have to write our first email template. The library uses a suffix convention to name | ||
subtemplate needed to generate subject, html and text versions. For instance, if we want to | ||
define an `Invitation` template, we will write three templates : | ||
* Invitation-BodyHtml.hbs | ||
* Invitation-BodyText.hbs | ||
* Invitation-Subject.hbs | ||
|
||
*Check the sample project to see the template contents* | ||
|
||
Then in our classes, we can require an `IEmailSender` which will allow us to send templated | ||
emails. | ||
|
||
```csharp | ||
public class HomeController : Controller | ||
{ | ||
private IEmailSender emailSender; | ||
|
||
public HomeController(IEmailSender emailSender) | ||
{ | ||
this.emailSender = emailSender; | ||
} | ||
|
||
public async Task<IActionResult> SendEmail() | ||
{ | ||
var user = new User | ||
{ | ||
Email = "[email protected]", | ||
DisplayName = "John Doe" | ||
}; | ||
|
||
var context = new | ||
{ | ||
ApplicationName = "Email Sender Sample", | ||
User = user | ||
}; | ||
|
||
await this.emailSender.SendTemplatedEmailAsync("Invitation", context, user); | ||
|
||
return RedirectToAction("Index"); | ||
} | ||
} | ||
``` | ||
|
||
## Supported providers | ||
|
||
We currently support two providers in addition to the testing oriented `InMemoryProvider`. | ||
|
||
### Smtp | ||
|
||
Thanks to mailkit library, you can send email using any smtp endpoint. | ||
|
||
### SendGrid | ||
|
||
We also bring basic sendgrid api support using our Sendgrid plugin. |
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
samples/GeekLearning.Email.Samples/GeekLearning.Email.Samples.csproj
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp1.1</TargetFramework> | ||
<PreserveCompilationContext>true</PreserveCompilationContext> | ||
<AssemblyName>GeekLearning.Email.Samples</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<PackageId>GeekLearning.Email.Samples</PackageId> | ||
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion> | ||
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Update="wwwroot\**\*;Views\**\*"> | ||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\GeekLearning.Email\GeekLearning.Email.csproj" /> | ||
<ProjectReference Include="..\..\src\GeekLearning.Email.SendGrid\GeekLearning.Email.SendGrid.csproj" /> | ||
<ProjectReference Include="..\..\src\GeekLearning.Email.InMemory\GeekLearning.Email.InMemory.csproj" /> | ||
<ProjectReference Include="..\..\src\GeekLearning.Email.Smtp\GeekLearning.Email.Smtp.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.2" /> | ||
<PackageReference Include="GeekLearning.Storage.FileSystem" Version="0.7.0" /> | ||
<PackageReference Include="GeekLearning.Templating.Handlebars" Version="0.5.1" /> | ||
</ItemGroup> | ||
|
||
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish"> | ||
<Exec Command="npm install" /> | ||
<Exec Command="bower install" /> | ||
<Exec Command="gulp clean" /> | ||
<Exec Command="gulp min" /> | ||
</Target> | ||
|
||
</Project> |
25 changes: 0 additions & 25 deletions
25
samples/GeekLearning.Email.Samples/GeekLearning.Email.Samples.xproj
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
"Port": "25", | ||
"UserName": "", | ||
"Password": "" | ||
}, | ||
} | ||
}, | ||
"DefaultSender": { | ||
"Email": "[email protected]", | ||
|
@@ -33,10 +33,7 @@ | |
"Storage": { | ||
"Stores": { | ||
"Templates": { | ||
"Provider": "FileSystem", | ||
"Parameters": { | ||
"Path": "Templates" | ||
} | ||
"ProviderType": "FileSystem" | ||
} | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/GeekLearning.Email.InMemory/GeekLearning.Email.InMemory.csproj
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Description>In Memory Provider for Geek Learning Email Abstractions.</Description> | ||
<VersionPrefix>0.0.1</VersionPrefix> | ||
<Authors>Geek Learning;Arnaud Auroux;Adrien Siffermann;Cyprien Autexier</Authors> | ||
<TargetFramework>netstandard1.1</TargetFramework> | ||
<AssemblyName>GeekLearning.Email.InMemory</AssemblyName> | ||
<PackageId>GeekLearning.Email.InMemory</PackageId> | ||
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\GeekLearning.Email\GeekLearning.Email.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.