mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-06 10:32:13 +01:00
Make login and password not required for sending email (#3764)
* Make login and password not required for sending email close #3656 * Add space * Remove unused "using" statements
This commit is contained in:
parent
3ede0a50f0
commit
d768314f03
1 changed files with 4 additions and 11 deletions
|
@ -1,13 +1,8 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Security;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Client.Models;
|
using BTCPayServer.Client.Models;
|
||||||
using MailKit.Net.Smtp;
|
using MailKit.Net.Smtp;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Services.Mails
|
namespace BTCPayServer.Services.Mails
|
||||||
{
|
{
|
||||||
|
@ -15,10 +10,7 @@ namespace BTCPayServer.Services.Mails
|
||||||
{
|
{
|
||||||
public bool IsComplete()
|
public bool IsComplete()
|
||||||
{
|
{
|
||||||
return !string.IsNullOrWhiteSpace(Server) &&
|
return !string.IsNullOrWhiteSpace(Server) && Port is int;
|
||||||
Port is int &&
|
|
||||||
!string.IsNullOrWhiteSpace(Login) &&
|
|
||||||
!string.IsNullOrWhiteSpace(Password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MimeMessage CreateMailMessage(MailboxAddress to, string subject, string message, bool isHtml)
|
public MimeMessage CreateMailMessage(MailboxAddress to, string subject, string message, bool isHtml)
|
||||||
|
@ -54,7 +46,8 @@ namespace BTCPayServer.Services.Mails
|
||||||
#pragma warning restore CA5359 // Do Not Disable Certificate Validation
|
#pragma warning restore CA5359 // Do Not Disable Certificate Validation
|
||||||
}
|
}
|
||||||
await client.ConnectAsync(Server, Port.Value, MailKit.Security.SecureSocketOptions.Auto, connectCancel.Token);
|
await client.ConnectAsync(Server, Port.Value, MailKit.Security.SecureSocketOptions.Auto, connectCancel.Token);
|
||||||
await client.AuthenticateAsync(Login, Password, connectCancel.Token);
|
if ((client.Capabilities & SmtpCapabilities.Authentication) != 0)
|
||||||
|
await client.AuthenticateAsync(Login ?? string.Empty, Password ?? string.Empty, connectCancel.Token);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue