Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions FluentEmail.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6DC215BD-05EF-49A6-ADBE-8AE399952EEC}"
EndProject
Expand Down Expand Up @@ -48,9 +48,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentEmail.Mailtrap.Tests"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentEmail.Mailtrap", "src\Senders\FluentEmail.Mailtrap\FluentEmail.Mailtrap.csproj", "{FD858CCC-4CF3-4899-B72F-F93C13832174}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentEmail.MailKit", "src\Senders\FluentEmail.MailKit\FluentEmail.MailKit.csproj", "{AEC98399-8C63-4362-B307-0DFB25FFC948}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentEmail.MailKit", "src\Senders\FluentEmail.MailKit\FluentEmail.MailKit.csproj", "{AEC98399-8C63-4362-B307-0DFB25FFC948}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentEmail.MailKit.Tests", "test\FluentEmail.MailKit.Tests\FluentEmail.MailKit.Tests.csproj", "{57718ED0-6B5D-419F-A5C5-1884BE3529A5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentEmail.MailKit.Tests", "test\FluentEmail.MailKit.Tests\FluentEmail.MailKit.Tests.csproj", "{57718ED0-6B5D-419F-A5C5-1884BE3529A5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FullFramework", "sample\FullFramework\FullFramework.csproj", "{BFD8889F-CF38-4359-9173-FD42FDDD6648}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -118,6 +120,10 @@ Global
{57718ED0-6B5D-419F-A5C5-1884BE3529A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57718ED0-6B5D-419F-A5C5-1884BE3529A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57718ED0-6B5D-419F-A5C5-1884BE3529A5}.Release|Any CPU.Build.0 = Release|Any CPU
{BFD8889F-CF38-4359-9173-FD42FDDD6648}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BFD8889F-CF38-4359-9173-FD42FDDD6648}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BFD8889F-CF38-4359-9173-FD42FDDD6648}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BFD8889F-CF38-4359-9173-FD42FDDD6648}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -142,6 +148,7 @@ Global
{FD858CCC-4CF3-4899-B72F-F93C13832174} = {926C0980-31D9-4449-903F-3C756044C28A}
{AEC98399-8C63-4362-B307-0DFB25FFC948} = {926C0980-31D9-4449-903F-3C756044C28A}
{57718ED0-6B5D-419F-A5C5-1884BE3529A5} = {4DADBE55-BD91-4D14-92EA-1BD0D1545145}
{BFD8889F-CF38-4359-9173-FD42FDDD6648} = {361467ED-E13F-45C7-8182-21A62D5F7B47}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {23736554-5288-4B30-9710-B4D9880BCF0B}
Expand Down
22 changes: 22 additions & 0 deletions sample/FullFramework/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
15 changes: 15 additions & 0 deletions sample/FullFramework/EmailTemplates/Test1.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@model dynamic
@{
}

<html>
<head>
</head>
<body>
<h1>A great email template</h1>
<p>Hi there @Model.Name, It's great to see you!</p>
</body>
</html>
349 changes: 349 additions & 0 deletions sample/FullFramework/FullFramework.csproj

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions sample/FullFramework/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using FluentEmail.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using FluentEmail.Razor;
using FluentEmail.Smtp;

namespace FullFramework
{
public class Program
{
static async Task Main(string[] args)
{
Email.DefaultSender = new SmtpSender(new SmtpClient("localhost", 25));
Email.DefaultRenderer = new RazorRenderer();

var model = new
{
Name = "Ben"
};

var assembly = Assembly.GetAssembly(typeof(FullFramework.Program));

await Email.From("fullframework@test.test")
.To("test3@test.test")
.Subject("console full framework")
.UsingTemplateFromEmbedded("FullFramework.EmailTemplates.Test1.cshtml", model, assembly)
.SendAsync();
}
}
}
36 changes: 36 additions & 0 deletions sample/FullFramework/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("FullFramework")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FullFramework")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bfd8889f-cf38-4359-9173-fd42fddd6648")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
81 changes: 81 additions & 0 deletions sample/FullFramework/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNetCore.Hosting.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Html.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Http.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Http.Features" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Mvc.Razor.Extensions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Razor" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Razor.Language" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Razor.Runtime" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.Common" version="2.8.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.CSharp" version="2.8.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.Razor" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.DotNet.PlatformAbstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Caching.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Caching.Memory" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyModel" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.FileProviders.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.FileProviders.Physical" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.FileSystemGlobbing" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Hosting.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Options" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Primitives" version="2.1.0" targetFramework="net472" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net472" />
<package id="NETStandard.Library" version="2.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net472" />
<package id="RazorLight" version="2.0.0-beta4" targetFramework="net472" />
<package id="System.AppContext" version="4.3.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net472" />
<package id="System.Collections.Immutable" version="1.3.1" targetFramework="net472" />
<package id="System.Console" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.StackTrace" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net472" />
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Globalization" version="4.3.0" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net472" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net472" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Linq" version="4.3.0" targetFramework="net472" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.0" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
<package id="System.Reflection" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection.Metadata" version="1.4.2" targetFramework="net472" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encoding.CodePages" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="4.5.0" targetFramework="net472" />
<package id="System.Threading" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Parallel" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Thread" version="4.3.0" targetFramework="net472" />
<package id="System.ValueTuple" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.XPath" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.XPath.XDocument" version="4.3.0" targetFramework="net472" />
</packages>
29 changes: 27 additions & 2 deletions sample/SampleWeb/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System.Threading.Tasks;
using System.Net.Mail;
using System.Reflection;
using System.Threading.Tasks;
using FluentEmail.Core;
using FluentEmail.Razor;
using FluentEmail.Smtp;
using Microsoft.AspNetCore.Mvc;

namespace SampleWeb.Controllers
Expand Down Expand Up @@ -45,10 +49,31 @@ await emailFactory.Create()
.To("test1@test.test")
.SetFrom("sender2@test.test")
.Subject("test email subject")
.UsingTemplate(@"hi @Model.Name this is the second email @(5 + 5)!", model1)
.UsingTemplate(@"hi @Model.Name this is the second email @(5 + 5)!", model2)
.SendAsync();

return Content("ok");
}

public async Task<IActionResult> NonDependencyInjectionTest()
{
Email.DefaultSender = new SmtpSender(new SmtpClient("localhost", 25));
Email.DefaultRenderer = new RazorRenderer();

var model = new
{
Name = "Ben"
};

var assembly = Assembly.GetAssembly(typeof(SampleWeb.Program));

await Email.From("nondependencyinjection@test.test")
.To("test2@test.test")
.Subject("old way")
.UsingTemplateFromEmbedded("SampleWeb.EmailTemplates.Test1.cshtml", model, assembly)
.SendAsync();

return Ok();
}
}
}
15 changes: 15 additions & 0 deletions sample/SampleWeb/EmailTemplates/Test1.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@model dynamic
@{
}

<html>
<head>
</head>
<body>
<h1>A great email template</h1>
<p>Hi there @Model.Name, It's great to see you!</p>
</body>
</html>
21 changes: 17 additions & 4 deletions sample/SampleWeb/SampleWeb.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>

<!-- The below two lines are important when using .NET Core 3+ -->
<PreserveCompilationReferences>true</PreserveCompilationReferences>
<PreserveCompilationContext>true</PreserveCompilationContext>
<!-- See https://github.com/toddams/RazorLight/issues/294#issuecomment-566147337 -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" />
<Content Remove="EmailTemplates\Test1.cshtml" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="EmailTemplates\Test1.cshtml" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 12 additions & 7 deletions sample/SampleWeb/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace SampleWeb
{
Expand All @@ -17,7 +18,7 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddControllersWithViews();

services
.AddFluentEmail("defaultemail@test.test")
Expand All @@ -26,25 +27,29 @@ public void ConfigureServices(IServiceCollection services)
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseMvc(routes =>
app.UseRouting();

app.UseEndpoints(endpoints =>
{
routes.MapRoute(
endpoints.MapControllerRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
Expand Down
Loading