<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MailKit.Net.Smtp;
using MailKit;
using MimeKit;
using Microsoft.AspNetCore.Builder;

namespace Api.Utility
{
    public class EmailSender
    {
        private AppConfig appConfig;
        public EmailSender(AppConfig appConfig)
        {
            this.appConfig = appConfig;
        }
        public Task InviteAsync(string email)
        {
            var smtp = appConfig.SMTPConfig;
            var bodyHtml = System.IO.File.ReadAllText(@"Utility\invation-email.html");
            bodyHtml = bodyHtml.Replace(@"{email}", email);

            var message = new MimeMessage();
            message.From.Add(new MailboxAddress("History in Paderborn", smtp.From));
            message.To.Add(new MailboxAddress("", email));
            message.Subject = "History in Paderborn App Einladung";
            message.Body = new TextPart("html")
            {
                Text = bodyHtml
        };

            using (var client = new SmtpClient())
            {
                // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
                client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                client.Connect(smtp.Server, smtp.Port, smtp.WithSSL);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove("XOAUTH2");

                // Note: only needed if the SMTP server requires authentication
                client.Authenticate(smtp.User, smtp.Password);<commit_msg>Path bugfix<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MailKit.Net.Smtp;
using MailKit;
using MimeKit;
using Microsoft.AspNetCore.Builder;
using System.IO;

namespace Api.Utility
{
    public class EmailSender
    {
        private AppConfig appConfig;
        public EmailSender(AppConfig appConfig)
        {
            this.appConfig = appConfig;
        }
        public Task InviteAsync(string email)
        {
            var smtp = appConfig.SMTPConfig;
            var bodyHtml = System.IO.File.ReadAllText(Path.Combine("Utility","invation-email.html"));
            bodyHtml = bodyHtml.Replace(@"{email}", email);

            var message = new MimeMessage();
            message.From.Add(new MailboxAddress("History in Paderborn", smtp.From));
            message.To.Add(new MailboxAddress("", email));
            message.Subject = "History in Paderborn App Einladung";
            message.Body = new TextPart("html")
            {
                Text = bodyHtml
        };

            using (var client = new SmtpClient())
            {
                // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
                client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                client.Connect(smtp.Server, smtp.Port, smtp.WithSSL);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove("XOAUTH2");

                // Note: only needed if the SMTP server requires authentication
                client.Authenticate(smtp.User, smtp.Password);
{'fraction_non_alphanumeric': 0.0942622950819672, 'fraction_numerical': 0.001756440281030445, 'mean_word_length': 2.1377410468319558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6515450', 'n_tokens_mistral': 917, 'n_tokens_neox': 891, 'n_words': 234}