Skip to content

Commit 1bb5f87

Browse files
committed
* Upgraded to Cofoundry v0.10 pre-release
* Added example project
1 parent 1132ba9 commit 1bb5f87

20 files changed

+341
-78
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,7 @@ src/.vs
101101

102102
# Cake Build
103103
/tools
104-
/artifacts
104+
/artifacts
105+
106+
appsettings.local.json
107+
APP_Data/

src/Cofoundry.Plugins.Mail.MailKit.sln

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26430.13
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.32126.315
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cofoundry.Plugins.Mail.MailKit", "Cofoundry.Plugins.Mail.MailKit\Cofoundry.Plugins.Mail.MailKit.csproj", "{8D628D8E-3AD8-4259-B08A-C7CC0FCC609D}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cofoundry.Plugins.Mail.MailKit", "Cofoundry.Plugins.Mail.MailKit\Cofoundry.Plugins.Mail.MailKit.csproj", "{8D628D8E-3AD8-4259-B08A-C7CC0FCC609D}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{DBD04643-D345-4DF5-AD0A-9A179649A4CA}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MailKitExample", "MailKitExample\MailKitExample.csproj", "{B78AFB4C-1ECF-4E72-AE5E-BC6638CE12C2}"
711
EndProject
812
Global
913
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,8 +19,18 @@ Global
1519
{8D628D8E-3AD8-4259-B08A-C7CC0FCC609D}.Debug|Any CPU.Build.0 = Debug|Any CPU
1620
{8D628D8E-3AD8-4259-B08A-C7CC0FCC609D}.Release|Any CPU.ActiveCfg = Release|Any CPU
1721
{8D628D8E-3AD8-4259-B08A-C7CC0FCC609D}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{B78AFB4C-1ECF-4E72-AE5E-BC6638CE12C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{B78AFB4C-1ECF-4E72-AE5E-BC6638CE12C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{B78AFB4C-1ECF-4E72-AE5E-BC6638CE12C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{B78AFB4C-1ECF-4E72-AE5E-BC6638CE12C2}.Release|Any CPU.Build.0 = Release|Any CPU
1826
EndGlobalSection
1927
GlobalSection(SolutionProperties) = preSolution
2028
HideSolutionNode = FALSE
2129
EndGlobalSection
30+
GlobalSection(NestedProjects) = preSolution
31+
{B78AFB4C-1ECF-4E72-AE5E-BC6638CE12C2} = {DBD04643-D345-4DF5-AD0A-9A179649A4CA}
32+
EndGlobalSection
33+
GlobalSection(ExtensibilityGlobals) = postSolution
34+
SolutionGuid = {795B0D5E-1717-4A6C-8111-2FE1E07DF4B6}
35+
EndGlobalSection
2236
EndGlobal

src/Cofoundry.Plugins.Mail.MailKit/Bootstrap/MailKitDependencyRegistration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void Register(IContainerRegister container)
1717
var overrideOptions = RegistrationOptions.Override();
1818

1919
container
20-
.Register<IMailDispatchService, MailKitMailDispatchService>(overrideOptions)
20+
.Register<IMailDispatchSession, MailKitMailDispatchSession>(overrideOptions)
2121
.Register<ISmtpClientConnectionConfiguration, SmtpClientConnectionConfiguration>()
2222
;
2323
}

src/Cofoundry.Plugins.Mail.MailKit/Cofoundry.Plugins.Mail.MailKit.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Cofoundry.Core" Version="0.9.2" />
20-
<PackageReference Include="MailKit" Version="2.10.1" />
19+
<PackageReference Include="Cofoundry.Core" Version="0.9.3-reworking-user-a0100" />
20+
<PackageReference Include="MailKit" Version="3.1.1" />
2121
</ItemGroup>
2222

2323
</Project>

src/Cofoundry.Plugins.Mail.MailKit/MailKitMailDispatchService.cs

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

src/Cofoundry.Plugins.Mail.MailKit/MilKitMailDispatchSession.cs renamed to src/Cofoundry.Plugins.Mail.MailKit/MailKitMailDispatchSession.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
using System;
77
using System.Collections.Generic;
88
using System.IO;
9-
using System.Linq;
10-
using System.Text;
119
using System.Threading.Tasks;
1210

1311
namespace Cofoundry.Plugins.Mail.MailKit
@@ -16,7 +14,7 @@ namespace Cofoundry.Plugins.Mail.MailKit
1614
/// Mail dispatch session that uses System.Net.Mail to
1715
/// dispatch email.
1816
/// </summary>
19-
public class MilKitMailDispatchSession : IMailDispatchSession
17+
public class MailKitMailDispatchSession : IMailDispatchSession
2018
{
2119
private readonly Queue<MimeMessage> _mailQueue = new Queue<MimeMessage>();
2220
private readonly Lazy<SmtpClient> _mailClient;
@@ -26,7 +24,7 @@ public class MilKitMailDispatchSession : IMailDispatchSession
2624

2725
private bool isDisposing = false;
2826

29-
public MilKitMailDispatchSession(
27+
public MailKitMailDispatchSession(
3028
MailSettings mailSettings,
3129
IPathResolver pathResolver,
3230
ISmtpClientConnectionConfiguration smtpClientConnectionConfiguration
@@ -82,8 +80,6 @@ public void Dispose()
8280
}
8381
}
8482

85-
#region private methods
86-
8783
private void ValidateNotDisposed()
8884
{
8985
if (isDisposing)
@@ -121,7 +117,7 @@ private SmtpClient CreateSmtpMailClient()
121117
if (isDisposing) return null;
122118
return new SmtpClient();
123119
}
124-
120+
125121
private MimeMessage FormatMessage(MailMessage message)
126122
{
127123
if (message == null) throw new ArgumentNullException(nameof(message));
@@ -196,7 +192,7 @@ private MailboxAddress CreateMailAddress(string email, string displayName)
196192
{
197193
if (string.IsNullOrEmpty(displayName))
198194
{
199-
mailAddress = new MailboxAddress(email);
195+
mailAddress = new MailboxAddress(null, email);
200196
}
201197
else
202198
{
@@ -226,7 +222,5 @@ private string GetMailDropPath()
226222

227223
return mailDropDirectory;
228224
}
229-
230-
#endregion
231225
}
232226
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Cofoundry.Core.Mail;
2+
3+
namespace MailKitExample
4+
{
5+
/// <summary>
6+
/// Each email consists of a template class and a set of
7+
/// template files. The template class is used as the view
8+
/// model and so you can include any custom propeties that
9+
/// want to make available in the template views.
10+
/// </summary>
11+
public class ExampleMailTemplate : IMailTemplate
12+
{
13+
/// <summary>
14+
/// Full path to the view file. This should not include the type part
15+
/// or file extension (i.e. '_html.cshml' or '_text.cshml') because this
16+
/// is automatically added.
17+
///
18+
/// You can place your templates wherever you like e.g. in the Cofoudry
19+
/// folder as we do here, or in the Views folder.
20+
/// </summary>
21+
public string ViewFile => "~/Cofoundry/MailTemplates/ExampleMailTemplate";
22+
23+
/// <summary>
24+
/// Used as the subject line in the email.
25+
/// </summary>
26+
public string Subject => "Example Mail";
27+
28+
/// <summary>
29+
/// This is a custom property to hold some data that we'd like to render in our view file.
30+
/// </summary>
31+
public string Message { get; set; }
32+
}
33+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@model MailKitExample.ExampleMailTemplate
2+
@*
3+
You can define either an html or plain text template, or both.
4+
The html template should have "_html" appended to the file name.
5+
*@
6+
@{
7+
Layout = null;
8+
}
9+
<h1>@Model.Subject</h1>
10+
<p>
11+
Message:
12+
</p>
13+
<p>
14+
@Model.Message
15+
</p>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@model MailKitExample.ExampleMailTemplate
2+
@*
3+
You can define either an html or plain text template, or both.
4+
The plain text template should have "_text" appended to the file name.
5+
If both templates are defined then a multi-part email is sent, where the
6+
plain text template is displayed when HTML is not permitted.
7+
*@
8+
@{
9+
Layout = null;
10+
}
11+
@Model.Subject
12+
13+
Message:
14+
15+
-------------------------------------------------
16+
@Model.Message
17+
--------------------------------------------------
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Cofoundry.Web.Admin" Version="0.9.3-reworking-user-a0100" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\Cofoundry.Plugins.Mail.MailKit\Cofoundry.Plugins.Mail.MailKit.csproj" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)