update nach Schuelererfassung
This commit is contained in:
46
BlazorApp - Kopie (4)/Helper/EMailSender.cs
Normal file
46
BlazorApp - Kopie (4)/Helper/EMailSender.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Helper
|
||||
{
|
||||
public class EmailSender : IEmailSender
|
||||
{
|
||||
|
||||
// Our private configuration variables
|
||||
private string host;
|
||||
private int port;
|
||||
private bool enableSSL;
|
||||
private string userName;
|
||||
private string password;
|
||||
|
||||
// Get our parameterized configuration
|
||||
public EmailSender(string host, int port, bool enableSSL, string userName, string password)
|
||||
{
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.enableSSL = enableSSL;
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
// Use our configuration to send the email by using SmtpClient
|
||||
public Task SendEmailAsync(string email, string subject, string htmlMessage)
|
||||
{
|
||||
|
||||
|
||||
var client = new SmtpClient(host, port)
|
||||
{
|
||||
Credentials = new NetworkCredential(userName, password),
|
||||
EnableSsl = enableSSL
|
||||
};
|
||||
return client.SendMailAsync(
|
||||
new MailMessage(userName, email, subject, htmlMessage) { IsBodyHtml = true }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user