2017-09-27 14:18:09 +09:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Mail;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace BTCPayServer.Services.Mails
|
|
|
|
|
{
|
|
|
|
|
public class EmailSettings
|
|
|
|
|
{
|
2017-10-27 17:53:04 +09:00
|
|
|
|
public string Server
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
2017-09-27 14:18:09 +09:00
|
|
|
|
|
2017-10-27 17:53:04 +09:00
|
|
|
|
public int? Port
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
2017-09-27 14:18:09 +09:00
|
|
|
|
|
2017-10-27 17:53:04 +09:00
|
|
|
|
public String Login
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
2017-09-27 14:18:09 +09:00
|
|
|
|
|
2017-10-27 17:53:04 +09:00
|
|
|
|
public String Password
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
[EmailAddress]
|
|
|
|
|
public string From
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
2017-09-27 14:18:09 +09:00
|
|
|
|
|
2017-10-27 17:53:04 +09:00
|
|
|
|
public bool EnableSSL
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
2017-09-27 14:18:09 +09:00
|
|
|
|
|
2018-05-05 01:42:42 +09:00
|
|
|
|
public bool IsComplete()
|
|
|
|
|
{
|
|
|
|
|
SmtpClient smtp = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
smtp = CreateSmtpClient();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 17:53:04 +09:00
|
|
|
|
public SmtpClient CreateSmtpClient()
|
|
|
|
|
{
|
|
|
|
|
SmtpClient client = new SmtpClient(Server, Port.Value);
|
2018-05-22 18:05:44 +09:00
|
|
|
|
client.EnableSsl = EnableSSL;
|
2017-10-27 17:53:04 +09:00
|
|
|
|
client.UseDefaultCredentials = false;
|
|
|
|
|
client.Credentials = new NetworkCredential(Login, Password);
|
|
|
|
|
client.DeliveryMethod = SmtpDeliveryMethod.Network;
|
|
|
|
|
client.Timeout = 10000;
|
|
|
|
|
return client;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-27 14:18:09 +09:00
|
|
|
|
}
|