diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 6cf68d2..7af4cb4 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -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:
diff --git a/src/NLog.MailKit/MailTarget.cs b/src/NLog.MailKit/MailTarget.cs
index af26068..c1f2131 100644
--- a/src/NLog.MailKit/MailTarget.cs
+++ b/src/NLog.MailKit/MailTarget.cs
@@ -91,7 +91,7 @@ public class MailTarget : TargetWithLayoutHeaderAndFooter
/// Initializes a new instance of the class.
///
///
- /// The default value of the layout is: ${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}
+ /// The default value of the Body-Layout is: ${message}${newline}
///
public MailTarget()
{
@@ -102,7 +102,7 @@ public MailTarget()
/// Initializes a new instance of the class.
///
///
- /// The default value of the layout is: ${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}
+ /// The default value of the Body-Layout is: ${message}${newline}
///
/// Name of the target.
public MailTarget(string name) : this()
@@ -309,7 +309,7 @@ private void ProcessSingleMailMessage(IEnumerable 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)));
@@ -341,8 +341,8 @@ private void ProcessSingleMailMessage(IEnumerable 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);
@@ -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);
}
@@ -477,6 +477,10 @@ private MimeMessage CreateMailMessage(LogEventInfo lastEvent, string body)
if (html && replaceNewlineWithBrTagInHtml)
{
newBody = newBody?.Replace(Environment.NewLine, "
");
+ if (newBody?.IndexOf('\n') >= 0)
+ {
+ newBody = newBody?.Replace("\n", "
");
+ }
}
var encoding = RenderLogEvent(Encoding, lastEvent, DefaultEncoding);
@@ -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);
}
}
diff --git a/src/NLog.MailKit/NLog.MailKit.csproj b/src/NLog.MailKit/NLog.MailKit.csproj
index 5a6c60c..37861c8 100644
--- a/src/NLog.MailKit/NLog.MailKit.csproj
+++ b/src/NLog.MailKit/NLog.MailKit.csproj
@@ -1,6 +1,6 @@
- netstandard2.0
+ netstandard2.0;netstandard2.1
Julian Verdurmen
NLog
NLog Mail Target for .NET Core & .NET Standard 2.0+ using MailKit.
@@ -31,7 +31,8 @@ If the mail target was already available on your platform, this package will ove
- 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
@@ -46,11 +47,11 @@ See https://github.com/NLog/NLog.MailKit/releases
RELEASE
-
+
-
+