btcpayserver/BTCPayServer/Services/Mails/EmailSettings.cs

68 lines
1.4 KiB
C#
Raw Normal View History

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
{
public string Server
{
get; set;
}
2017-09-27 14:18:09 +09:00
public int? Port
{
get; set;
}
2017-09-27 14:18:09 +09:00
public string Login
{
get; set;
}
[DataType(DataType.Password)]
public string Password
{
get; set;
}
[EmailAddress]
public string From
{
get; set;
}
2017-09-27 14:18:09 +09:00
2019-03-03 16:47:37 -06:00
[Display(Name = "Enable SSL")]
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;
}
public SmtpClient CreateSmtpClient()
{
SmtpClient client = new SmtpClient(Server, Port.Value);
2018-05-22 18:05:44 +09:00
client.EnableSsl = EnableSSL;
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
}