feat: email config is now loaded from fs
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
31409be192
commit
766e6054dc
4 changed files with 19 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,6 +6,7 @@ ImageBoardServerApp/wwwroot/img/dynamic
|
||||||
*.db-shm
|
*.db-shm
|
||||||
*.db-wal
|
*.db-wal
|
||||||
Migrations/
|
Migrations/
|
||||||
|
/ImageBoardServerApp/Data/creds.json
|
||||||
|
|
||||||
## Ignore Visual Studio temporary files, build results, and
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
## files generated by popular Visual Studio add-ons.
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.13" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.13" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Radzen.Blazor" Version="4.10.4" />
|
<PackageReference Include="Radzen.Blazor" Version="4.10.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -44,6 +44,9 @@ ImageThumbnailOptions options = new ImageThumbnailOptions("wwwroot/img/", "thumb
|
||||||
options.ImageQuality = 75L;
|
options.ImageQuality = 75L;
|
||||||
app.UseImageThumbnail(options);
|
app.UseImageThumbnail(options);
|
||||||
|
|
||||||
|
//Load mail config
|
||||||
|
Postman.loadConfig();
|
||||||
|
|
||||||
//Log onto Mail Server
|
//Log onto Mail Server
|
||||||
Postman.logon();
|
Postman.logon();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace ImageBoardServerApp.Util;
|
namespace ImageBoardServerApp.Util;
|
||||||
|
|
||||||
|
@ -7,19 +8,29 @@ public static class Postman
|
||||||
{
|
{
|
||||||
private static SmtpClient smtpClient;
|
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()
|
public static void logon()
|
||||||
{
|
{
|
||||||
smtpClient = new SmtpClient("smtp.bulletboards.xyz")
|
smtpClient = new SmtpClient(values["email-server"].ToString())
|
||||||
{
|
{
|
||||||
Port = 587,
|
Port = 587,
|
||||||
Credentials = new NetworkCredential("noreply@bulletboards.xyz", "frogARdI,97,#"),
|
Credentials = new NetworkCredential(values["email-address"].ToString(), values["email-password"].ToString()),
|
||||||
EnableSsl = true,
|
EnableSsl = true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendMail(string to, string subj, string body)
|
public static void sendMail(string to, string subj, string body)
|
||||||
{
|
{
|
||||||
smtpClient.Send("noreply@bulletboards.xyz", to, subj, body);
|
smtpClient.Send(values["email-address"].ToString(), to, subj, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue