bulletboards/ImageBoardServerApp/Util/Postman.cs

36 lines
988 B
C#
Raw Normal View History

using System.Net;
using System.Net.Mail;
using Newtonsoft.Json;
namespace ImageBoardServerApp.Util;
public static class Postman
{
private static SmtpClient smtpClient;
public static Dictionary<string, object> values = new Dictionary<string, object>();
public static void loadConfig()
{
values =
JsonConvert.DeserializeObject<Dictionary<string, object>>(File.ReadAllText("Data/creds.json"));
Console.WriteLine(File.ReadAllText("Data/creds.json"));
}
public static void logon()
{
smtpClient = new SmtpClient(values["email-server"].ToString())
{
Port = 587,
Credentials = new NetworkCredential(values["email-address"].ToString(), values["email-password"].ToString()),
EnableSsl = true,
};
}
public static void sendMail(string to, string subj, string body)
{
smtpClient.Send(values["email-address"].ToString(), to, subj, body);
}
}