<commit_before>using System;
using System.Net;
using System.Net.Mail;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace CmsEngine.Application.Helpers.Email
{
    public class EmailSender : IEmailSender
    {
        private readonly EmailSettings _emailSettings;
        private readonly ILogger<EmailSender> _logger;

        public EmailSender(IOptions<EmailSettings> emailSettings, ILogger<EmailSender> logger)
        {
            _emailSettings = emailSettings.Value;
            _logger = logger;
        }

        public async Task SendEmailAsync(ContactForm mailEditModel)
        {
            await Execute(mailEditModel);
        }

        private async Task Execute(ContactForm mailEditModel)
        {
            _logger.LogInformation(mailEditModel.ToString());

            try
            {
                string from = mailEditModel.From ?? _emailSettings.Username;

                MailMessage mail = new MailMessage(new MailAddress(from), new MailAddress(mailEditModel.To));

                if (!string.IsNullOrWhiteSpace(_emailSettings.CcEmail))
                {
                    mail.CC.Add(new MailAddress(_emailSettings.CcEmail));
                }

                if (!string.IsNullOrWhiteSpace(_emailSettings.BccEmail))
                {
                    mail.Bcc.Add(new MailAddress(_emailSettings.BccEmail));
                }

                mail.Subject = $"🌐 CmsEngine - {mailEditModel.Subject}";
                mail.Body = mailEditModel.Message;
                mail.IsBodyHtml = false;
                mail.Priority = MailPriority.Normal;

                using (var smtp = new SmtpClient(_emailSettings.Domain, _emailSettings.Port))
                {
                    smtp.EnableSsl = true;
                    smtp.Timeout = 10000;
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials = new NetworkCredential(_emailSettings.Username, _emailSettings.Password);

                    await smtp.SendMailAsync(mail);<commit_msg>Refactored EmailSender<commit_after>using System;
using System.Net;
using System.Net.Mail;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace CmsEngine.Application.Helpers.Email
{
    public class EmailSender : IEmailSender
    {
        private readonly EmailSettings _emailSettings;
        private readonly ILogger<EmailSender> _logger;

        public EmailSender(IOptions<EmailSettings> emailSettings, ILogger<EmailSender> logger)
        {
            _emailSettings = emailSettings.Value;
            _logger = logger;
        }

        public async Task SendEmailAsync(ContactForm mailEditModel)
        {
            await Execute(mailEditModel);
        }

        private async Task Execute(ContactForm mailEditModel)
        {
            _logger.LogInformation(mailEditModel.ToString());

            try
            {
                string from = mailEditModel.From ?? _emailSettings.Username;

                MailMessage mail = new MailMessage
                {
                    From = new MailAddress(from),
                    Subject = $"🌐 CmsEngine - {mailEditModel.Subject}",
                    Body = mailEditModel.Message,
                    IsBodyHtml = false,
                    Priority = MailPriority.Normal
                };

                if (!string.IsNullOrWhiteSpace(mailEditModel.To))
                {
                    mail.To.Add(mailEditModel.To);
                }

                if (!string.IsNullOrWhiteSpace(_emailSettings.CcEmail))
                {
                    mail.CC.Add(_emailSettings.CcEmail);
                }

                if (!string.IsNullOrWhiteSpace(_emailSettings.BccEmail))
                {
                    mail.Bcc.Add(_emailSettings.BccEmail);
                }

                using (var smtp = new SmtpClient(_emailSettings.Domain, _emailSettings.Port))
                {
                    smtp.EnableSsl = true;
                    smtp.Timeout = 10000;
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials = new NetworkCredential(_emailSettings.Username, _emailSettings.Password);

                    await smtp.SendMailAsync(mail);
{'fraction_non_alphanumeric': 0.07548865423500337, 'fraction_numerical': 0.0022466861379465287, 'mean_word_length': 1.7790262172284643, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3428364', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1065, 'n_words': 197}