* Maintain FaKrosno api to handle Hangfire
* Added checking of missing EdiCo based on EdiCoTranslate and send email every 30 minutes * Added Admin Scheduler view
This commit is contained in:
30
FaKrosnoApi/Services/EmailService.cs
Normal file
30
FaKrosnoApi/Services/EmailService.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using FaKrosnoApi.Models;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FaKrosnoApi.Services;
|
||||
|
||||
public class EmailService(IOptions<EmailSettingsModel> emailSettings) : IEmailService
|
||||
{
|
||||
private readonly EmailSettingsModel _emailSettings = emailSettings.Value;
|
||||
|
||||
public void SendEmail(string subject, string body)
|
||||
{
|
||||
using var smtpClient = new SmtpClient(_emailSettings.SmtpServer, _emailSettings.Port);
|
||||
smtpClient.EnableSsl = true;
|
||||
smtpClient.UseDefaultCredentials = false;
|
||||
smtpClient.Credentials = new NetworkCredential(_emailSettings.SenderEmail, _emailSettings.SenderPassword);
|
||||
|
||||
var mailMessage = new MailMessage
|
||||
{
|
||||
From = new MailAddress(_emailSettings.SenderEmail),
|
||||
Subject = subject,
|
||||
Body = body
|
||||
};
|
||||
|
||||
mailMessage.To.Add(_emailSettings.RecipientEmail);
|
||||
|
||||
smtpClient.Send(mailMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user