Skip to content

Commit

Permalink
Merge pull request #55 from ChangemakerStudios/develop
Browse files Browse the repository at this point in the history
Latest
  • Loading branch information
Jaben authored May 28, 2017
2 parents 8ae8e6a + 1048eb3 commit 3bc6170
Show file tree
Hide file tree
Showing 42 changed files with 326 additions and 219 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
![Papercut Logo](https://raw.githubusercontent.com/ChangemakerStudios/Papercut/develop/graphics/PapercutLogo.png)<br>
![Papercut Logo](https://raw.githubusercontent.com/ChangemakerStudios/Papercut/develop/graphics/PapercutLogo.png)
The Simple SMTP Desktop Email Receiver

<br>
[![Build status](https://ci.appveyor.com/api/projects/status/bs2asxoafdwbkcxa?svg=true)](https://ci.appveyor.com/project/Jaben/papercut)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Jaben/Papercut?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)


##What it does
## What it does
Ever need to test emails from an application or web site but don't want them accidently being sent or having to deal with the hassle of setting up a test email server? Papercut is a quick email viewer with a built-in SMTP server designed to only receive messages. It doesn't enforce any restrictions how you send your email. It allows you to view the whole email-chilada: body, html, headers, attachment down to the naughty raw bits. It can be set to run on startup and sits quietly minimized in the tray giving you a balloon popup when a new message arrives.

##Download Now
####[ClickOnce](https://papercut.codeplex.com/downloads/get/clickOnce/Papercut.application) | [Releases (zip files)](https://github.com/ChangemakerStudios/Papercut/releases)
## Download Now
#### [ClickOnce](https://papercut.codeplex.com/downloads/get/clickOnce/Papercut.application) | [Releases (zip files)](https://github.com/ChangemakerStudios/Papercut/releases)

##Features
####Instant Feedback When New Email Arrives
## Features
#### Instant Feedback When New Email Arrives
![Instant Feedback When New Email Arrives](http://www.tinygecko.com/downloads/Papercut-v3.1.0-S2.png)
####Rich and Detailed View of Received Email
#### Rich and Detailed View of Received Email
![Rich and Detailed View of Received Email](http://www.tinygecko.com/images/Papercut/Papercut-Main.png)
####View and Download the Mime Sections of your Email
#### View and Download the Mime Sections of your Email
![View and Download the Mime Sections of your Email](http://www.tinygecko.com/images/Papercut/Papercut-Mime.png)
####In Version 4 the Raw View Returns
#### In Version 4 the Raw View Returns
![In Version 4 the Raw View Returns](http://www.tinygecko.com/images/Papercut/Papercut-Raw.png)
####New in Version 4.4: Logging View
#### New in Version 4.4: Logging View
![In Version 4.4: Logging View](http://www.tinygecko.com/images/Papercut/Papercut-Log.png)

##Papercut Background Service
## Papercut Background Service
Papercut has an optional "always on" service to receive emails even when the client is not running. It's manually installed by [Downloading the Papercut.Service.zip](https://github.com/ChangemakerStudios/Papercut/releases), unzipping and [following the service installation instructions](https://github.com/ChangemakerStudios/Papercut/tree/develop/src/Papercut.Service).

##License
Papercut is Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0"> Apache License, Version 2.0.
## License
Papercut is Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
os: Visual Studio 2015
os: Visual Studio 2017

configuration: Release

Expand Down
3 changes: 1 addition & 2 deletions chocolately/papercut.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>papercut</id>
<version>2016.4.3</version>
<version>4.8.0.0</version>
<title>Papercut</title>
<authors>Jaben</authors>
<owners>Jaben</owners>
Expand All @@ -21,7 +21,6 @@ Papercut is the answer. Papercut is a simplified SMTP server designed to only re
<file src="..\src\Papercut.UI\bin\Release\Papercut.exe" target="bin\Papercut.exe" />
<file src="..\src\Papercut.UI\bin\Release\Papercut.exe.config" target="bin\Papercut.exe.config" />
<file src="..\src\Papercut.UI\bin\Release\Readme.eml" target="bin\Readme.eml" />
<file src="..\src\Papercut.UI\bin\Release\Readme.eml" target="bin\Readme.eml" />
<file src="tools\Papercut.exe.gui" target="bin\Papercut.exe.gui" />
</files>
</package>
4 changes: 2 additions & 2 deletions src/Papercut.Common/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 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("4.6.0.0")]
[assembly: AssemblyFileVersion("4.6.0.0")]
[assembly: AssemblyVersion("4.8.0.0")]
[assembly: AssemblyFileVersion("4.8.0.0")]
94 changes: 2 additions & 92 deletions src/Papercut.Core/Infrastructure/Container/PapercutCoreModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal class PapercutCoreModule : Module
{
protected override void Load(ContainerBuilder builder)
{
this.RegisterPluginArchitecture(builder);
new RegisterPlugins(Log.Logger).Register(builder, PapercutContainer.ExtensionAssemblies);

//builder.RegisterAssemblyModules(PapercutContainer.ExtensionAssemblies);

Expand Down Expand Up @@ -91,97 +91,7 @@ protected override void Load(ContainerBuilder builder)
.AsSelf()
.SingleInstance();

RegisterLogger(builder);
}

private void RegisterPluginArchitecture(ContainerBuilder builder)
{
var scannableAssemblies = PapercutContainer.ExtensionAssemblies;

var pluginModules =
scannableAssemblies.SelectMany(a => a.GetExportedTypes())
.Where(s =>
{
var interfaces = s.GetInterfaces();
return interfaces.Contains(typeof(IDiscoverableModule)) || interfaces.Contains(typeof(IPluginModule));
})
.Distinct()
.ToList();

foreach (var pluginType in pluginModules)
{
try
{
// register and load...
var module = Activator.CreateInstance(pluginType) as IDiscoverableModule;

if (module != null)
{
builder.RegisterModule(module.Module);
}

var plugin = module as IPluginModule;
if (plugin != null)
{
PluginStore.Instance.Add(plugin);
}
}
catch (Exception ex)
{
Log.Logger.Error(ex, "Failure Loading Plugin Module Type {PluginModuleType}", pluginType.FullName);
}
}
}

private static void RegisterLogger(ContainerBuilder builder)
{
builder.Register(c =>
{
var appMeta = c.Resolve<IAppMeta>();

//string logFilePath = Path.Combine(
// AppDomain.CurrentDomain.BaseDirectory,
// "Logs",
// $"{appMeta.AppName}.log");

LoggerConfiguration logConfiguration =
new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Verbose()
#else
.MinimumLevel.Information()
#endif
.Enrich.With<EnvironmentEnricher>()
.Enrich.WithThreadId()
.Enrich.FromLogContext()
.Enrich.WithProperty("AppName", appMeta.AppName)
.Enrich.WithProperty("AppVersion", appMeta.AppVersion)
.WriteTo.ColoredConsole();
//.WriteTo.RollingFile(logFilePath);

// publish event so additional sinks, enrichers, etc can be added before logger creation is finalized.
try
{
c.Resolve<IMessageBus>().Publish(new ConfigureLoggerEvent(logConfiguration));
}
catch (Exception ex)
{
Debug.WriteLine("Failure Publishing ConfigurationLoggerEvent: " + ex.ToString());
}

// support self-logging
Serilog.Debugging.SelfLog.Out = Console.Error;

return logConfiguration;
}).AsSelf().SingleInstance();

builder.Register(
c =>
{
Log.Logger = c.Resolve<LoggerConfiguration>().CreateLogger();

return Log.Logger;
}).As<ILogger>().SingleInstance();
new RegisterLogger().Register(builder);
}

protected override void AttachToComponentRegistration(
Expand Down
91 changes: 91 additions & 0 deletions src/Papercut.Core/Infrastructure/Logging/RegisterLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Papercut
//
// Copyright © 2008 - 2012 Ken Robertson
// Copyright © 2013 - 2017 Jaben Cargman
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


namespace Papercut.Core.Infrastructure.Logging
{
using System;
using System.Diagnostics;
using System.IO;

using Autofac;

using Papercut.Common.Domain;
using Papercut.Core.Domain.Application;

using Serilog;
using Serilog.Debugging;

public class RegisterLogger
{
public void Register(ContainerBuilder builder)
{
builder.Register(
c =>
{
var appMeta = c.Resolve<IAppMeta>();

string logFilePath = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"Logs",
$"{appMeta.AppName}.log");

LoggerConfiguration logConfiguration =
new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Verbose()
#else
.MinimumLevel.Information()
#endif
.Enrich.With<EnvironmentEnricher>()
.Enrich.WithThreadId()
.Enrich.FromLogContext()
.Enrich.WithProperty("AppName", appMeta.AppName)
.Enrich.WithProperty("AppVersion", appMeta.AppVersion)
.WriteTo.ColoredConsole()
.WriteTo.RollingFile(logFilePath);

// publish event so additional sinks, enrichers, etc can be added before logger creation is finalized.
try
{
c.Resolve<IMessageBus>().Publish(new ConfigureLoggerEvent(logConfiguration));
}
catch (Exception ex)
{
Debug.WriteLine("Failure Publishing ConfigurationLoggerEvent: " + ex.ToString());
}

// support self-logging
SelfLog.Out = Console.Error;

return logConfiguration;
})
.AsSelf()
.SingleInstance();

builder.Register(
c =>
{
Log.Logger = c.Resolve<LoggerConfiguration>().CreateLogger();

return Log.Logger;
})
.As<ILogger>()
.SingleInstance();
}
}
}
79 changes: 79 additions & 0 deletions src/Papercut.Core/Infrastructure/Plugins/RegisterPlugins.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Papercut
//
// Copyright © 2008 - 2012 Ken Robertson
// Copyright © 2013 - 2017 Jaben Cargman
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Papercut.Core.Infrastructure.Plugins
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

using Autofac;

using Papercut.Common.Extensions;

using Serilog;

public class RegisterPlugins
{
private readonly ILogger _logger;

public RegisterPlugins(ILogger logger)
{
this._logger = logger.ForContext<RegisterPlugins>();
}

public void Register(ContainerBuilder builder, IEnumerable<Assembly> scannableAssemblies)
{
var pluginModules =
scannableAssemblies.IfNullEmpty()
.SelectMany(a => a.GetExportedTypes())
.Where(
s =>
{
var interfaces = s.GetInterfaces();
return interfaces.Contains(typeof(IDiscoverableModule)) || interfaces.Contains(typeof(IPluginModule));
})
.Distinct()
.ToList();

foreach (var pluginType in pluginModules)
{
try
{
// register and load...
var module = Activator.CreateInstance(pluginType) as IDiscoverableModule;

if (module != null)
{
builder.RegisterModule(module.Module);
}

var plugin = module as IPluginModule;
if (plugin != null)
{
PluginStore.Instance.Add(plugin);
}
}
catch (Exception ex)
{
_logger.Error(ex, "Failure Loading Plugin Module Type {PluginModuleType}", pluginType.FullName);
}
}
}
}
}
7 changes: 4 additions & 3 deletions src/Papercut.Core/Papercut.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.10.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Serilog, Version=1.5.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.1.5.14\lib\net40\Serilog.dll</HintPath>
Expand Down Expand Up @@ -80,6 +79,7 @@
<Compile Include="Domain\Paths\IPathTemplatesProvider.cs" />
<Compile Include="Domain\Paths\MessagePathConfigurator.cs" />
<Compile Include="Infrastructure\Lifecycle\AppForceShutdownEvent.cs" />
<Compile Include="Infrastructure\Logging\RegisterLogger.cs" />
<Compile Include="Infrastructure\Network\AppProcessExchangeEvent.cs" />
<Compile Include="Infrastructure\MessageBus\AutofacMessageBus.cs" />
<Compile Include="Infrastructure\Network\BaseBindEvent.cs" />
Expand Down Expand Up @@ -119,6 +119,7 @@
<Compile Include="Domain\Message\NewMessageEventArgs.cs" />
<Compile Include="Infrastructure\Container\PapercutContainer.cs" />
<Compile Include="Infrastructure\Container\PapercutCoreModule.cs" />
<Compile Include="Infrastructure\Plugins\RegisterPlugins.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Domain\Rules\IRule.cs" />
<Compile Include="Domain\Rules\IRuleDispatcher.cs" />
Expand Down
4 changes: 2 additions & 2 deletions src/Papercut.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("4.6.0.0")]
[assembly: AssemblyFileVersion("4.6.0.0")]
[assembly: AssemblyVersion("4.8.0.0")]
[assembly: AssemblyFileVersion("4.8.0.0")]
Loading

0 comments on commit 3bc6170

Please sign in to comment.