Skip to content

Commit a672ec1

Browse files
authored
Merge pull request #23 from geeklearningio/release/0.5.0
Release/0.5.0
2 parents 75f574a + 23a6b69 commit a672ec1

39 files changed

+433
-554
lines changed

GeekLearning.Email.sln

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25420.1
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26430.6
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email", "src\GeekLearning.Email\GeekLearning.Email.xproj", "{474EEA84-EBFB-4925-BDC2-619C21E7EBC9}"
7-
EndProject
86
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{01E85AC0-EFEF-4564-9EE9-9A124776B72E}"
97
EndProject
108
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "items", "items", "{96D48864-D85C-4364-A96C-3BD8DD86F6E0}"
119
ProjectSection(SolutionItems) = preProject
1210
.gitattributes = .gitattributes
1311
.gitignore = .gitignore
1412
GitVersion.yml = GitVersion.yml
15-
global.json = global.json
1613
LICENSE.md = LICENSE.md
1714
README.md = README.md
1815
EndProjectSection
1916
EndProject
2017
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{68985ADC-F984-4594-AF38-6A6EEFB2DFDE}"
2118
EndProject
22-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.Samples", "samples\GeekLearning.Email.Samples\GeekLearning.Email.Samples.xproj", "{EDA94EFF-7FF4-4C79-BC52-93BC7E696FF6}"
23-
EndProject
2419
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8DF5B138-1052-4991-88EF-FF23AE1DCC34}"
2520
EndProject
26-
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}"
21+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email", "src\GeekLearning.Email\GeekLearning.Email.csproj", "{474EEA84-EBFB-4925-BDC2-619C21E7EBC9}"
22+
EndProject
23+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.Samples", "samples\GeekLearning.Email.Samples\GeekLearning.Email.Samples.csproj", "{EDA94EFF-7FF4-4C79-BC52-93BC7E696FF6}"
24+
EndProject
25+
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}"
2726
EndProject
28-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.SendGrid", "src\GeekLearning.Email.SendGrid\GeekLearning.Email.SendGrid.xproj", "{8701FCC7-0420-4E57-9FD5-5B3943FD255E}"
27+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.SendGrid", "src\GeekLearning.Email.SendGrid\GeekLearning.Email.SendGrid.csproj", "{8701FCC7-0420-4E57-9FD5-5B3943FD255E}"
2928
EndProject
30-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.InMemory", "src\GeekLearning.Email.InMemory\GeekLearning.Email.InMemory.xproj", "{8C83A791-0A38-4E42-8261-3614B336737E}"
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.InMemory", "src\GeekLearning.Email.InMemory\GeekLearning.Email.InMemory.csproj", "{8C83A791-0A38-4E42-8261-3614B336737E}"
3130
EndProject
32-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Email.Smtp", "src\GeekLearning.Email.Smtp\GeekLearning.Email.Smtp.xproj", "{707CA417-5EED-467A-A449-73A606089835}"
31+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeekLearning.Email.Smtp", "src\GeekLearning.Email.Smtp\GeekLearning.Email.Smtp.csproj", "{707CA417-5EED-467A-A449-73A606089835}"
3332
EndProject
3433
Global
3534
GlobalSection(SolutionConfigurationPlatforms) = preSolution

NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="GL Unstable" value="https://www.myget.org/F/gl-unstable/api/v3/index.json" />
5+
</packageSources>
6+
</configuration>

README.md

Lines changed: 129 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,133 @@
1-
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/GeekLearning.Email.svg?maxAge=2592000&label=GeekLearning.Email)](https://www.nuget.org/packages/GeekLearning.Email)
2-
[![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)
3-
[![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)
4-
[![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)
1+
[![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Email.svg?style=flat-square&label=NuGet)](https://www.nuget.org/packages/GeekLearning.Email/)
52
[![Build Status](https://geeklearning.visualstudio.com/_apis/public/build/definitions/f841b266-7595-4d01-9ee1-4864cf65aa73/28/badge)](#)
63

74
# gl-dotnet-email
85

9-
Coming Soon !
6+
GeekLearning.Email provide an abstraction over various email providers. It brings builtin templates
7+
support thanks to our [templating library](https://github.com/geeklearningio/gl-dotnet-templating).
8+
It also bring email interception support so you can easily redirect email to developers/tester
9+
inboxes in developement environement.
10+
11+
## Getting Started
12+
13+
14+
In your project.json add required dependencies :
15+
```
16+
"GeekLearning.Storage.FileSystem": "0.6.0-*",
17+
"GeekLearning.Templating.Handlebars": "0.5.0-*",
18+
19+
"GeekLearning.Email": "0.5.0-*",
20+
"GeekLearning.Email.Smtp": ""0.5.0-*"
21+
```
22+
23+
Then add required settings in your `appsettings.json` file.
24+
25+
In this example, we will use FileSystem provider to configure a storage provider which will load files from
26+
a `Templates` folder relative to Application Root. This could be configured to use
27+
an Azure Container instead (see storage documentation).
28+
29+
We will configure `Email` to use the `Smtp` provider. If any Mockup Recipients are defined, they will
30+
receive the email in place of the original Recipients.
31+
32+
```json
33+
"Email": {
34+
"Provider": {
35+
"Type": "Smtp",
36+
"Parameters": {
37+
"Host": "127.0.0.1",
38+
"Port": "25",
39+
"UserName": "",
40+
"Password": ""
41+
},
42+
},
43+
"DefaultSender": {
44+
"Email": "no-reply@yourdomain.com",
45+
"DisplayName": "Your Company Name"
46+
},
47+
"TemplateStorage": "Templates",
48+
"Mockup": {
49+
"Recipients": [],
50+
"Exceptions": {
51+
"Emails": [],
52+
"Domains": []
53+
}
54+
}
55+
},
56+
"Storage": {
57+
"Stores": {
58+
"Templates": {
59+
"Provider": "FileSystem",
60+
"Parameters": {
61+
"Path": "Templates"
62+
}
63+
}
64+
}
65+
}
66+
```
67+
68+
Then in your `Startup.cs` file add required dependencies and configuration to the DI container.
69+
70+
```csharp
71+
services.AddStorage().AddFileSystemStorage(this.HostingEnvironment.ContentRootPath);
72+
services.Configure<StorageOptions>(Configuration.GetSection("Storage"));
73+
services.AddTemplating().AddHandlebars();
74+
75+
services.AddEmail()
76+
.AddSmtpEmail();
77+
services.Configure<EmailOptions>(Configuration.GetSection("Email"));
78+
```
79+
80+
Then we will have to write our first email template. The library uses a suffix convention to name
81+
subtemplate needed to generate subject, html and text versions. For instance, if we want to
82+
define an `Invitation` template, we will write three templates :
83+
* Invitation-BodyHtml.hbs
84+
* Invitation-BodyText.hbs
85+
* Invitation-Subject.hbs
86+
87+
*Check the sample project to see the template contents*
88+
89+
Then in our classes, we can require an `IEmailSender` which will allow us to send templated
90+
emails.
91+
92+
```csharp
93+
public class HomeController : Controller
94+
{
95+
private IEmailSender emailSender;
96+
97+
public HomeController(IEmailSender emailSender)
98+
{
99+
this.emailSender = emailSender;
100+
}
101+
102+
public async Task<IActionResult> SendEmail()
103+
{
104+
var user = new User
105+
{
106+
Email = "john@doe.me",
107+
DisplayName = "John Doe"
108+
};
109+
110+
var context = new
111+
{
112+
ApplicationName = "Email Sender Sample",
113+
User = user
114+
};
115+
116+
await this.emailSender.SendTemplatedEmailAsync("Invitation", context, user);
117+
118+
return RedirectToAction("Index");
119+
}
120+
}
121+
```
122+
123+
## Supported providers
124+
125+
We currently support two providers in addition to the testing oriented `InMemoryProvider`.
126+
127+
### Smtp
128+
129+
Thanks to mailkit library, you can send email using any smtp endpoint.
130+
131+
### SendGrid
132+
133+
We also bring basic sendgrid api support using our Sendgrid plugin.

global.json

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp1.1</TargetFramework>
5+
<PreserveCompilationContext>true</PreserveCompilationContext>
6+
<AssemblyName>GeekLearning.Email.Samples</AssemblyName>
7+
<OutputType>Exe</OutputType>
8+
<PackageId>GeekLearning.Email.Samples</PackageId>
9+
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
10+
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<None Update="wwwroot\**\*;Views\**\*">
15+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\src\GeekLearning.Email\GeekLearning.Email.csproj" />
21+
<ProjectReference Include="..\..\src\GeekLearning.Email.SendGrid\GeekLearning.Email.SendGrid.csproj" />
22+
<ProjectReference Include="..\..\src\GeekLearning.Email.InMemory\GeekLearning.Email.InMemory.csproj" />
23+
<ProjectReference Include="..\..\src\GeekLearning.Email.Smtp\GeekLearning.Email.Smtp.csproj" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.2" />
28+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
29+
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" />
30+
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
31+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
32+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.2" />
33+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
34+
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
35+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.2" />
36+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
37+
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
38+
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.2" />
39+
<PackageReference Include="GeekLearning.Storage.FileSystem" Version="0.7.0" />
40+
<PackageReference Include="GeekLearning.Templating.Handlebars" Version="0.5.1" />
41+
</ItemGroup>
42+
43+
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
44+
<Exec Command="npm install" />
45+
<Exec Command="bower install" />
46+
<Exec Command="gulp clean" />
47+
<Exec Command="gulp min" />
48+
</Target>
49+
50+
</Project>

samples/GeekLearning.Email.Samples/GeekLearning.Email.Samples.xproj

Lines changed: 0 additions & 25 deletions
This file was deleted.

samples/GeekLearning.Email.Samples/Startup.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public void ConfigureServices(IServiceCollection services)
3333
// Add framework services.
3434
services.AddMvc();
3535

36-
services.AddStorage().AddFileSystemStorage(this.HostingEnvironment.ContentRootPath);
37-
services.Configure<StorageOptions>(Configuration.GetSection("Storage"));
36+
services.AddStorage(Configuration).AddFileSystemStorage(this.HostingEnvironment.ContentRootPath);
3837
services.AddTemplating().AddHandlebars();
3938

4039
services.AddEmail()

samples/GeekLearning.Email.Samples/appsettings.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"Port": "25",
1616
"UserName": "",
1717
"Password": ""
18-
},
18+
}
1919
},
2020
"DefaultSender": {
2121
"Email": "no-reply@geeklearning.io",
@@ -33,10 +33,7 @@
3333
"Storage": {
3434
"Stores": {
3535
"Templates": {
36-
"Provider": "FileSystem",
37-
"Parameters": {
38-
"Path": "Templates"
39-
}
36+
"ProviderType": "FileSystem"
4037
}
4138
}
4239
}

samples/GeekLearning.Email.Samples/project.json

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>In Memory Provider for Geek Learning Email Abstractions.</Description>
5+
<VersionPrefix>0.0.1</VersionPrefix>
6+
<Authors>Geek Learning;Arnaud Auroux;Adrien Siffermann;Cyprien Autexier</Authors>
7+
<TargetFramework>netstandard1.1</TargetFramework>
8+
<AssemblyName>GeekLearning.Email.InMemory</AssemblyName>
9+
<PackageId>GeekLearning.Email.InMemory</PackageId>
10+
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\GeekLearning.Email\GeekLearning.Email.csproj" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<Folder Include="Properties\" />
19+
</ItemGroup>
20+
21+
</Project>

0 commit comments

Comments
 (0)