using System.Text.Encodings.Web;
using BTCPayServer.Services.Mails;
using MimeKit;
namespace BTCPayServer.Services
{
public static class EmailSenderExtensions
{
private static string BODY_STYLE = "font-family: Open Sans, Helvetica Neue,Arial,sans-serif; font-color: #292929;";
private static string HEADER_HTML = "
BTCPay Server
";
private static string BUTTON_HTML = "{button_description}";
private static string CallToAction(string actionName, string actionLink)
{
string button = $"{BUTTON_HTML}".Replace("{button_description}", actionName, System.StringComparison.InvariantCulture);
button = button.Replace("{button_link}", actionLink, System.StringComparison.InvariantCulture);
return button;
}
public static void SendEmailConfirmation(this IEmailSender emailSender, MailboxAddress address, string link)
{
emailSender.SendEmail(address, "BTCPay Server: Confirm your email",
$"Please confirm your account by clicking this link.");
}
public static void SendApprovalConfirmation(this IEmailSender emailSender, MailboxAddress address, string link)
{
emailSender.SendEmail(address, "BTCPay Server: Your account has been approved",
$"Your account has been approved and you can now login here.");
}
public static void SendResetPassword(this IEmailSender emailSender, MailboxAddress address, string link)
{
var body = $"A request has been made to reset your BTCPay Server password. Please set your password by clicking below.
{CallToAction("Update Password", HtmlEncoder.Default.Encode(link))}";
emailSender.SendEmail(address, "BTCPay Server: Update Password", $"{HEADER_HTML}{body}");
}
public static void SendInvitation(this IEmailSender emailSender, MailboxAddress address, string link)
{
emailSender.SendEmail(address, "BTCPay Server: Invitation",
$"Please complete your account setup by clicking this link.");
}
public static void SendNewUserInfo(this IEmailSender emailSender, MailboxAddress address, string newUserInfo, string link)
{
emailSender.SendEmail(address, $"BTCPay Server: {newUserInfo}",
$"{newUserInfo}. You can verify and approve the account here: User details");
}
}
}