Skip to content

Commit

Permalink
Updated dependency NLog to v5.2.2 (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot committed Aug 12, 2023
1 parent d9b390a commit c346164
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ variables:
Solution: 'src/NLog.MailKit.sln'
BuildPlatform: 'Any CPU'
BuildConfiguration: 'Release'
Version: '5.1.3'
Version: '5.1.0'
FullVersion: '$(Version).$(Build.BuildId)'

steps:
Expand Down
25 changes: 16 additions & 9 deletions src/NLog.MailKit/MailTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class MailTarget : TargetWithLayoutHeaderAndFooter
/// Initializes a new instance of the <see cref="MailTarget" /> class.
/// </summary>
/// <remarks>
/// The default value of the layout is: <code>${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}</code>
/// The default value of the Body-Layout is: <code>${message}${newline}</code>
/// </remarks>
public MailTarget()
{
Expand All @@ -102,7 +102,7 @@ public MailTarget()
/// Initializes a new instance of the <see cref="MailTarget" /> class.
/// </summary>
/// <remarks>
/// The default value of the layout is: <code>${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}</code>
/// The default value of the Body-Layout is: <code>${message}${newline}</code>
/// </remarks>
/// <param name="name">Name of the target.</param>
public MailTarget(string name) : this()
Expand Down Expand Up @@ -309,7 +309,7 @@ private void ProcessSingleMailMessage(IEnumerable<AsyncLogEventInfo> events)
{
client.Timeout = RenderLogEvent(Timeout, lastEvent);

var renderedHost = SmtpServer.Render(lastEvent);
var renderedHost = RenderLogEvent(SmtpServer, lastEvent);
if (string.IsNullOrEmpty(renderedHost))
{
throw new NLogRuntimeException(string.Format(RequiredPropertyIsEmptyFormat, nameof(SmtpServer)));
Expand Down Expand Up @@ -341,8 +341,8 @@ private void ProcessSingleMailMessage(IEnumerable<AsyncLogEventInfo> events)
var smtpAuthentication = RenderLogEvent(SmtpAuthentication, LogEventInfo.CreateNullEvent());
if (smtpAuthentication == SmtpAuthenticationMode.Basic)
{
var userName = SmtpUserName?.Render(lastEvent);
var password = SmtpPassword?.Render(lastEvent);
var userName = RenderLogEvent(SmtpUserName, lastEvent);
var password = RenderLogEvent(SmtpPassword, lastEvent);

InternalLogger.Debug("Authenticate with username '{0}'", userName);
client.Authenticate(userName, password);
Expand Down Expand Up @@ -465,9 +465,9 @@ private MimeMessage CreateMailMessage(LogEventInfo lastEvent, string body)

msg.Subject = (RenderLogEvent(Subject, lastEvent) ?? string.Empty).Trim();

if (Priority != null)
var renderedPriority = RenderLogEvent(Priority, lastEvent);
if (!string.IsNullOrEmpty(renderedPriority))
{
var renderedPriority = Priority.Render(lastEvent);
msg.Priority = ParseMessagePriority(renderedPriority);
}

Expand All @@ -477,6 +477,10 @@ private MimeMessage CreateMailMessage(LogEventInfo lastEvent, string body)
if (html && replaceNewlineWithBrTagInHtml)
{
newBody = newBody?.Replace(Environment.NewLine, "<br/>");
if (newBody?.IndexOf('\n') >= 0)
{
newBody = newBody?.Replace("\n", "<br/>");
}
}

var encoding = RenderLogEvent(Encoding, lastEvent, DefaultEncoding);
Expand All @@ -486,16 +490,19 @@ private MimeMessage CreateMailMessage(LogEventInfo lastEvent, string body)
ContentType = { Charset = encoding?.WebName }
};


if (MailHeaders?.Count > 0)
{
for (int i = 0; i < MailHeaders.Count; i++)
{
var headerName = MailHeaders[i].Name;
if (string.IsNullOrEmpty(headerName))
continue;

string headerValue = RenderLogEvent(MailHeaders[i].Layout, lastEvent);
if (headerValue is null)
continue;

msg.Headers.Add(MailHeaders[i].Name, headerValue);
msg.Headers.Add(headerName, headerValue);
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/NLog.MailKit/NLog.MailKit.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<Authors>Julian Verdurmen</Authors>
<Company>NLog</Company>
<Description>NLog Mail Target for .NET Core &amp; .NET Standard 2.0+ using MailKit.
Expand Down Expand Up @@ -31,7 +31,8 @@ If the mail target was already available on your platform, this package will ove
<PackageReleaseNotes>
- Added support for email headers
- Added target-alias mailkit
- Updated to NLog v5.1.3
- Updated to NLog v5.2.2
- Updated to MailKit v3.3.0

See https://github.com/NLog/NLog.MailKit/releases

Expand All @@ -46,11 +47,11 @@ See https://github.com/NLog/NLog.MailKit/releases
<DefineConstants>RELEASE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MailKit" Version="3.2.0" />
<PackageReference Include="MailKit" Version="3.3.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.1.3" />
<PackageReference Include="NLog" Version="5.2.2" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\README.md">
Expand Down

0 comments on commit c346164

Please sign in to comment.