add SMTP sender email
This commit is contained in:
parent
b8fb230a0e
commit
1276c0269e
|
@ -127,7 +127,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<Section Name="SMTP" ResourceKey="SMTPSettings">
|
||||
<Section Name="SMTP" Heading="SMTP Settings" ResourceKey="SMTPSettings">
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
|
@ -163,7 +163,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="username" HelpText="Enter the username for your SMTP account. Please note that this field is required as it will be used as the Sender of the emails." ResourceKey="SmptUsername">Username: </Label>
|
||||
<Label For="username" HelpText="Enter the username for your SMTP account" ResourceKey="SmptUsername">Username: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="username" class="form-control" @bind="@_smtpusername" />
|
||||
|
@ -177,6 +177,14 @@
|
|||
<input id="password" type="password" class="form-control" @bind="@_smtppassword" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="sender" HelpText="Enter the email which emails will be sent from. Please note that this email address may need to be authorized with the SMTP server." ResourceKey="SmptSender">Email Sender: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="sender" class="form-control" @bind="@_smtpsender" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</Section>
|
||||
<Section Name="PWA" Heading="Progressive Web Application Settings" ResourceKey="PWASettings">
|
||||
|
@ -242,6 +250,7 @@
|
|||
private string _smtpssl = "False";
|
||||
private string _smtpusername = string.Empty;
|
||||
private string _smtppassword = string.Empty;
|
||||
private string _smtpsender = string.Empty;
|
||||
private string _pwaisenabled;
|
||||
private int _pwaappiconfileid = -1;
|
||||
private FileManager _pwaappiconfilemanager;
|
||||
|
@ -297,6 +306,7 @@
|
|||
_smtpssl = SettingService.GetSetting(settings, "SMTPSSL", "False");
|
||||
_smtpusername = SettingService.GetSetting(settings, "SMTPUsername", string.Empty);
|
||||
_smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty);
|
||||
_smtpsender = SettingService.GetSetting(settings, "SMTPSender", string.Empty);
|
||||
|
||||
_pwaisenabled = site.PwaIsEnabled.ToString();
|
||||
|
||||
|
@ -442,6 +452,7 @@
|
|||
SettingService.SetSetting(settings, "SMTPSSL", _smtpssl);
|
||||
SettingService.SetSetting(settings, "SMTPUsername", _smtpusername);
|
||||
SettingService.SetSetting(settings, "SMTPPassword", _smtppassword);
|
||||
SettingService.SetSetting(settings, "SMTPSender", _smtpsender);
|
||||
await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId);
|
||||
|
||||
await logger.LogInformation("Site Settings Saved {Site}", site);
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Oqtane.Infrastructure
|
|||
if (settings.ContainsKey("SMTPHost") && settings["SMTPHost"] != "" &&
|
||||
settings.ContainsKey("SMTPPort") && settings["SMTPPort"] != "" &&
|
||||
settings.ContainsKey("SMTPSSL") && settings["SMTPSSL"] != "" &&
|
||||
settings.ContainsKey("SMTPUsername") && settings["SMTPUsername"] != "")
|
||||
settings.ContainsKey("SMTPSender") && settings["SMTPSender"] != "")
|
||||
{
|
||||
// construct SMTP Client
|
||||
var client = new SmtpClient()
|
||||
|
@ -72,7 +72,7 @@ namespace Oqtane.Infrastructure
|
|||
foreach (Notification notification in notifications)
|
||||
{
|
||||
MailMessage mailMessage = new MailMessage();
|
||||
mailMessage.From = new MailAddress(settings["SMTPUsername"], site.Name);
|
||||
mailMessage.From = new MailAddress(settings["SMTPSender"], site.Name);
|
||||
mailMessage.Subject = notification.Subject;
|
||||
if (notification.FromUserId != null)
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ namespace Oqtane.Infrastructure
|
|||
}
|
||||
else
|
||||
{
|
||||
log += "SMTP Not Configured Properly In Site Settings - Host, Port, SSL, And Username Are All Required" + "<br />";
|
||||
log += "SMTP Not Configured Properly In Site Settings - Host, Port, SSL, And Sender Are All Required" + "<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user