Skip to content

Commit 42eeab7

Browse files
authored
Merge pull request #10 from myloveCc/dev
Fix issues #9 and update version to 2.0.2
2 parents af312a5 + 37422e4 commit 42eeab7

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ MailKit extension for asp.net core
1010
# Install with nuget
1111

1212
```
13-
Install-Package NETCore.MailKit -Version 2.0.1
13+
Install-Package NETCore.MailKit -Version 2.0.2
1414
```
1515

1616
# Install with .NET CLI
1717
```
18-
dotnet add package NETCore.MailKit --version 2.0.1
18+
dotnet add package NETCore.MailKit --version 2.0.2
1919
```
2020

2121
# How to use
@@ -39,6 +39,8 @@ public void ConfigureServices(IServiceCollection services)
3939
Port = Convert.ToInt32(Configuration["Port"]),
4040
SenderName = Configuration["SenderName"],
4141
SenderEmail = Configuration["SenderEmail"],
42+
43+
// can be optional with no authentication
4244
Account = Configuration["Account"],
4345
           Password = Configuration["Password"],
4446
           // enable ssl or tls

example/NETCore.MailKit.Web/Startup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public void ConfigureServices(IServiceCollection services)
4949
Port = Convert.ToInt32(Configuration["Port"]),
5050
SenderName = Configuration["SenderName"],
5151
SenderEmail = Configuration["SenderEmail"],
52+
53+
//can be optional with no authentication
5254
Account = Configuration["Account"],
5355
Password = Configuration["Password"]
5456
});

src/NETCore.MailKit/MailKitProvider.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace NETCore.MailKit
1111
{
12-
public class MailKitProvider : IMailKitProvider
12+
public class MailKitProvider:IMailKitProvider
1313
{
1414
public MailKitOptions Options { get; private set; }
1515

@@ -41,7 +41,7 @@ private SmtpClient InitSmtpClient()
4141

4242
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
4343

44-
44+
4545
if (!Options.Security)
4646
{
4747
client.Connect(Options.Server, Options.Port, SecureSocketOptions.None);
@@ -55,8 +55,12 @@ private SmtpClient InitSmtpClient()
5555
// Note: since we don't have an OAuth2 token, disable
5656
// the XOAUTH2 authentication mechanism.
5757
client.AuthenticationMechanisms.Remove("XOAUTH2");
58-
// user login smtp server
59-
client.Authenticate(Options.Account, Options.Password);
58+
59+
// user login smtp server (fix issue #9)
60+
if (!string.IsNullOrEmpty(Options.Account) && !string.IsNullOrEmpty(Options.Password))
61+
{
62+
client.Authenticate(Options.Account, Options.Password);
63+
}
6064

6165
return client;
6266
}

src/NETCore.MailKit/NETCore.MailKit.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
6-
<Version>2.0.1</Version>
6+
<Version>2.0.2</Version>
77
<Authors>Lvcc</Authors>
88
<Company />
99
<Description>MailKit extension for asp.net core. Easy send email in asp.net core project.</Description>
@@ -12,13 +12,14 @@
1212
<RepositoryUrl>https://github.com/myloveCc/NETCore.MailKit</RepositoryUrl>
1313
<PackageTags>MailKit ASP.NETCore</PackageTags>
1414
<RepositoryType>git</RepositoryType>
15-
<AssemblyVersion>2.0.1.0</AssemblyVersion>
16-
<FileVersion>2.0.1.0</FileVersion>
17-
<PackageReleaseNotes>MailKit ASP.NETCore 2.0.0 ,update to .net core 2.0 rtm.</PackageReleaseNotes>
15+
<AssemblyVersion>2.0.2.0</AssemblyVersion>
16+
<FileVersion>2.0.2.0</FileVersion>
17+
<PackageReleaseNotes>1:Update Mailkit to version 2.0.1.
18+
2:Fix Issues #9 about "no authentication error"</PackageReleaseNotes>
1819
</PropertyGroup>
1920

2021
<ItemGroup>
21-
<PackageReference Include="MailKit" Version="1.18.1.1" />
22+
<PackageReference Include="MailKit" Version="2.0.1" />
2223
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
2324
</ItemGroup>
2425

0 commit comments

Comments
 (0)