redirect do forum po mailu, bug fix, setings wywalone w kosmos

This commit is contained in:
nlitkowski 2018-12-20 01:59:38 +01:00
parent 3607ce2f2b
commit e9ed7d4b77
4 changed files with 14 additions and 16 deletions

View File

@ -4,6 +4,7 @@ using System.Web.Mvc;
using System.Web.ModelBinding;
using System;
using Newtonsoft.Json;
using System.Configuration;
namespace MailSender.Controllers
{
@ -40,16 +41,19 @@ namespace MailSender.Controllers
{
if (ModelState.IsValid)
{
var smtpClient = new SmtpClient(Settings.smtpServer, Settings.smtpPort)
var smtpClient = new SmtpClient(ConfigurationManager.AppSettings["smtp-server"],
Int32.Parse(ConfigurationManager.AppSettings["smtp-port"]))
{
Credentials = new NetworkCredential(Settings.user, Settings.pass),
Credentials = new NetworkCredential(
ConfigurationManager.AppSettings["user-mail"],
ConfigurationManager.AppSettings["pass-mail"]),
EnableSsl = true
};
smtpClient.Send(Settings.user, model.EMailTo, model.Subject, model.Content);
return RedirectToAction("Index");
smtpClient.Send(ConfigurationManager.AppSettings["user-mail"], model.EMailTo, model.Subject, model.Content);
return Redirect(ConfigurationManager.AppSettings["forum-address"]);
}
else
return RedirectToAction("Error", new { errMsg = "Error nie umiesz pisac maila menelu" });
return RedirectToAction("Error", new { errMsg = "Błąd wysyłania wiadomości e-mail." });
}
}
}

View File

@ -175,7 +175,6 @@
</Compile>
<Compile Include="Models\MailModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\bootstrap-theme.css" />

View File

@ -1,10 +0,0 @@
namespace MailSender
{
public class Settings
{
public static string smtpServer = "smtp.gmail.com";
public static int smtpPort = 587;
public static string user = "ttestowy504@gmail.com";
public static string pass = "ChyzySoftware";
}
}

View File

@ -10,6 +10,11 @@
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="user-mail" value="ttestowy504@gmail.com" />
<add key="pass-mail" value="ChyzySoftware" />
<add key="smtp-port" value="587" />
<add key="smtp-server" value="smtp.gmail.com" />
<add key="forum-address" value="http://forum-inzynieria1.azurewebsites.net/home/index"/>
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />