Skip to content

Commit

Permalink
Merge pull request #23 from geeklearningio/release/0.5.0
Browse files Browse the repository at this point in the history
Release/0.5.0
  • Loading branch information
asiffermann authored Oct 2, 2017
2 parents 75f574a + 23a6b69 commit a672ec1
Show file tree
Hide file tree
Showing 39 changed files with 433 additions and 554 deletions.
21 changes: 10 additions & 11 deletions GeekLearning.Email.sln
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email", "src\GeekLearning.Email\GeekLearning.Email.xproj", "{474EEA84-EBFB-4925-BDC2-619C21E7EBC9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{01E85AC0-EFEF-4564-9EE9-9A124776B72E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "items", "items", "{96D48864-D85C-4364-A96C-3BD8DD86F6E0}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
GitVersion.yml = GitVersion.yml
global.json = global.json
LICENSE.md = LICENSE.md
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{68985ADC-F984-4594-AF38-6A6EEFB2DFDE}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.Samples", "samples\GeekLearning.Email.Samples\GeekLearning.Email.Samples.xproj", "{EDA94EFF-7FF4-4C79-BC52-93BC7E696FF6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8DF5B138-1052-4991-88EF-FF23AE1DCC34}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.Integration.Test", "tests\GeekLearning.Email.Integration.Test\GeekLearning.Email.Integration.Test.xproj", "{86B313ED-41D4-424F-A172-7D0E8EEE5E49}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email", "src\GeekLearning.Email\GeekLearning.Email.csproj", "{474EEA84-EBFB-4925-BDC2-619C21E7EBC9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.Samples", "samples\GeekLearning.Email.Samples\GeekLearning.Email.Samples.csproj", "{EDA94EFF-7FF4-4C79-BC52-93BC7E696FF6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.Integration.Test", "tests\GeekLearning.Email.Integration.Test\GeekLearning.Email.Integration.Test.csproj", "{86B313ED-41D4-424F-A172-7D0E8EEE5E49}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.SendGrid", "src\GeekLearning.Email.SendGrid\GeekLearning.Email.SendGrid.xproj", "{8701FCC7-0420-4E57-9FD5-5B3943FD255E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.SendGrid", "src\GeekLearning.Email.SendGrid\GeekLearning.Email.SendGrid.csproj", "{8701FCC7-0420-4E57-9FD5-5B3943FD255E}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.InMemory", "src\GeekLearning.Email.InMemory\GeekLearning.Email.InMemory.xproj", "{8C83A791-0A38-4E42-8261-3614B336737E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.InMemory", "src\GeekLearning.Email.InMemory\GeekLearning.Email.InMemory.csproj", "{8C83A791-0A38-4E42-8261-3614B336737E}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.Smtp", "src\GeekLearning.Email.Smtp\GeekLearning.Email.Smtp.xproj", "{707CA417-5EED-467A-A449-73A606089835}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.Smtp", "src\GeekLearning.Email.Smtp\GeekLearning.Email.Smtp.csproj", "{707CA417-5EED-467A-A449-73A606089835}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
6 changes: 6 additions & 0 deletions NuGet.Config
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>
134 changes: 129 additions & 5 deletions README.md
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.
4 changes: 0 additions & 4 deletions global.json

This file was deleted.

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>

This file was deleted.

3 changes: 1 addition & 2 deletions samples/GeekLearning.Email.Samples/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public void ConfigureServices(IServiceCollection services)
// Add framework services.
services.AddMvc();

services.AddStorage().AddFileSystemStorage(this.HostingEnvironment.ContentRootPath);
services.Configure<StorageOptions>(Configuration.GetSection("Storage"));
services.AddStorage(Configuration).AddFileSystemStorage(this.HostingEnvironment.ContentRootPath);
services.AddTemplating().AddHandlebars();

services.AddEmail()
Expand Down
7 changes: 2 additions & 5 deletions samples/GeekLearning.Email.Samples/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"Port": "25",
"UserName": "",
"Password": ""
},
}
},
"DefaultSender": {
"Email": "[email protected]",
Expand All @@ -33,10 +33,7 @@
"Storage": {
"Stores": {
"Templates": {
"Provider": "FileSystem",
"Parameters": {
"Path": "Templates"
}
"ProviderType": "FileSystem"
}
}
}
Expand Down
69 changes: 0 additions & 69 deletions samples/GeekLearning.Email.Samples/project.json

This file was deleted.

21 changes: 21 additions & 0 deletions src/GeekLearning.Email.InMemory/GeekLearning.Email.InMemory.csproj
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>
Loading

0 comments on commit a672ec1

Please sign in to comment.