Skip to content

Commit

Permalink
improved email
Browse files Browse the repository at this point in the history
  • Loading branch information
dlidstrom committed Mar 28, 2022
1 parent 6afbcfa commit 058c9f6
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 62 deletions.
38 changes: 0 additions & 38 deletions Snittlistan.Web/Infrastructure/MailHttpContext.cs

This file was deleted.

2 changes: 2 additions & 0 deletions Snittlistan.Web/Models/EmailState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ protected EmailState(

public static string OwnerEmail { get; } = ConfigurationManager.AppSettings["OwnerEmail"];

public static string BccEmail { get; } = ConfigurationManager.AppSettings["BccEmail"];

public string Bcc { get; }

public string From { get; }
Expand Down
2 changes: 1 addition & 1 deletion Snittlistan.Web/Models/InviteUserEmail_State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Snittlistan.Web.Models;
public class InviteUserEmail_State : EmailState
{
public InviteUserEmail_State(string to, string subject, string activationUri)
: base(OwnerEmail, to, OwnerEmail, subject)
: base(OwnerEmail, to, BccEmail, subject)
{
ActivationUri = activationUri;
}
Expand Down
2 changes: 1 addition & 1 deletion Snittlistan.Web/Models/MatchRegisteredEmail_State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public MatchRegisteredEmail_State(
int opponentScore,
ResultSeriesReadModel resultSeriesReadModel,
ResultHeaderReadModel resultHeaderReadModel)
: base(from, to, OwnerEmail, subject)
: base(from, to, BccEmail, subject)
{
Team = team;
Opponent = opponent;
Expand Down
2 changes: 1 addition & 1 deletion Snittlistan.Web/Models/OneTimePasswordEmail_State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public OneTimePasswordEmail_State(
string to,
string subject,
string oneTimePassword)
: base(OwnerEmail, to, OwnerEmail, subject)
: base(OwnerEmail, to, BccEmail, subject)
{
OneTimePassword = oneTimePassword;
}
Expand Down
2 changes: 1 addition & 1 deletion Snittlistan.Web/Models/SendEmail_State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public SendEmail_State(
string replyTo,
string subject,
string content)
: base(OwnerEmail, to, OwnerEmail, subject)
: base(OwnerEmail, to, BccEmail, subject)
{
ReplyTo = replyTo;
Content = content;
Expand Down
2 changes: 1 addition & 1 deletion Snittlistan.Web/Models/UpdateRosterEmail_State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public UpdateRosterEmail_State(
int oilProfileId,
string oilProfileName,
DateTime matchDate)
: base(OwnerEmail, playerEmail, OwnerEmail, "Uttagning har uppdaterats")
: base(OwnerEmail, playerEmail, BccEmail, "Uttagning har uppdaterats")
{
PlayerEmail = playerEmail;
Name = name;
Expand Down
2 changes: 1 addition & 1 deletion Snittlistan.Web/Models/UserRegisteredEmail_State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public UserRegisteredEmail_State(
string subject,
string id,
string activationKey)
: base(OwnerEmail, to, OwnerEmail, subject)
: base(OwnerEmail, to, BccEmail, subject)
{
Id = id;
ActivationKey = activationKey;
Expand Down
1 change: 0 additions & 1 deletion Snittlistan.Web/Snittlistan.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,6 @@
<Compile Include="Infrastructure\IoC\WindsorDependencyResolver.cs" />
<Compile Include="Infrastructure\JavaScriptException.cs" />
<Compile Include="Infrastructure\LowercaseRoute.cs" />
<Compile Include="Infrastructure\MailHttpContext.cs" />
<Compile Include="Infrastructure\MailHttpResponse.cs" />
<Compile Include="Infrastructure\Results\ElmahResult.cs" />
<Compile Include="Infrastructure\Results\NotFoundViewResult.cs" />
Expand Down
4 changes: 3 additions & 1 deletion Snittlistan.Web/Views/Emails/InviteUser.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
To: @Model.To
From: @Model.From
Bcc: @Model.Bcc
Subject: @Model.Subject
Subject: @(string.Format(
"=?utf-8?B?{0}?=",
Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("🎳 " + Model.Subject))))
Content-Type: text/html; charset=utf-8

<html>
Expand Down
4 changes: 3 additions & 1 deletion Snittlistan.Web/Views/Emails/Mail.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ From: @Model.From
@:Reply-To: @Model.ReplyTo
}
Bcc: @Model.Bcc
Subject: @Model.Subject
Subject: @(string.Format(
"=?utf-8?B?{0}?=",
Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(Model.Subject))))
Content-Type: text/html; charset=utf-8

<html>
Expand Down
4 changes: 3 additions & 1 deletion Snittlistan.Web/Views/Emails/MatchRegistered.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

To: @Model.To
From: @Model.From
Subject: @Model.Subject
Subject: @(string.Format(
"=?utf-8?B?{0}?=",
Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("🎳 " + Model.Subject))))
Content-Type: text/html; charset=utf-8

<html>
Expand Down
6 changes: 4 additions & 2 deletions Snittlistan.Web/Views/Emails/OneTimePassword.cshtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
@model Snittlistan.Web.Models.OneTimePasswordEmail
@model Snittlistan.Web.Models.OneTimePasswordEmail
To: @Model.To
From: @Model.From
Bcc: @Model.Bcc
Subject: @Model.Subject
Subject: @(string.Format(
"=?utf-8?B?{0}?=",
Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("🎳 " + Model.Subject))))
Content-Type: text/html; charset=utf-8

<html>
Expand Down
4 changes: 3 additions & 1 deletion Snittlistan.Web/Views/Emails/UpdateRoster.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ To: @Model.PlayerEmail
From: @Model.From
Reply-To: @Model.ReplyToEmail
Bcc: @Model.Bcc
Subject: @Model.Subject
Subject: @(string.Format(
"=?utf-8?B?{0}?=",
Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("🎳 " + Model.Subject))))
Content-Type: text/html; charset=utf-8

<html>
Expand Down
4 changes: 3 additions & 1 deletion Snittlistan.Web/Views/Emails/UserRegistered.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
To: @ViewBag.To
From: @ViewBag.From
Bcc: @ViewBag.Bcc
Subject: @ViewBag.Subject
Subject: @(string.Format(
"=?utf-8?B?{0}?=",
Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("🎳 " + Model.Subject))))
Content-Type: text/html; charset=utf-8

<html>
Expand Down
7 changes: 2 additions & 5 deletions Snittlistan.Web/Web.Release.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
finds an atrribute "name" that has a value of "MyDB".
-->

<appSettings>
<add key="MainUrl" value="http://snittlistan.se" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
</appSettings>
<system.net>
<mailSettings>
<smtp xdt:Transform="Replace" deliveryMethod="Network">
<network host="smtp.gmail.com"
<network host="smtp.sendgrid.net"
port="587"
enableSsl="true"
userName="[email protected]"
userName="apikey"
password=""
defaultCredentials="false" />
</smtp>
Expand Down
6 changes: 2 additions & 4 deletions Snittlistan.Web/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
<add key="PreserveLoginUrl" value="true"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
<add key="OwnerEmail" value="[email protected]"/>
<add key="MainUrl" value="http://snittlistan.se"/>
<add key="Domain" value="snittlistan.se"/>
<add key="ApplicationName" value="Snittlistan"/>
<add key="OwnerEmail" value="" />
<add key="BccEmail" value="" />
<add key="TaskQueue" value=".\Private$\taskqueue"/>
<add key="ElitemedalsTemplateFilename" value="C:\Programming\Snittlistan\elitmarke-ifyllbar1.pdf"/>
<add key="elmah.mvc.disableHandler" value="false"/>
Expand Down
24 changes: 23 additions & 1 deletion Snittlistan.main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
Installed OR EMAIL_PASSWORD
</Condition>

<Condition Message="ELMAH_EMAIL_PASSWORD variable must be set in the command line">
Installed OR ELMAH_EMAIL_PASSWORD
</Condition>

<Condition Message="DB_HOST variable must be set in the command line">
Installed OR DB_HOST
</Condition>
Expand All @@ -63,6 +67,14 @@
Installed OR DB_PASSWORD
</Condition>

<Condition Message="OWNER_EMAIL variable must be set in the command line">
Installed OR OWNER_EMAIL
</Condition>

<Condition Message="BCC_EMAIL variable must be set in the command line">
Installed OR BCC_EMAIL
</Condition>

<?include conditions.wxi?>

<CustomAction Id="VerifyMatches_Cmd"
Expand Down Expand Up @@ -143,6 +155,16 @@
File="[SnittlistanWebDir]Web.config"
ElementPath="/configuration/appSettings/add[\[]@key='ElitemedalsTemplateFilename'[\]]/@value"
Value="[SnittlistanWebDir]elitmarke-ifyllbar1.pdf" />
<util:XmlFile Id="OwnerEmailSetting"
Action="setValue"
File="[SnittlistanWebDir]Web.config"
ElementPath="/configuration/appSettings/add[\[]@key='OwnerEmail'[\]]/@value"
Value="[OWNER_EMAIL]" />
<util:XmlFile Id="BccEmailSetting"
Action="setValue"
File="[SnittlistanWebDir]Web.config"
ElementPath="/configuration/appSettings/add[\[]@key='BccEmail'[\]]/@value"
Value="[BCC_EMAIL]" />
<util:XmlFile Id="MailSettings"
Action="setValue"
File="[SnittlistanWebDir]Web.config"
Expand All @@ -152,7 +174,7 @@
Action="setValue"
File="[SnittlistanWebDir]Web.config"
ElementPath="/configuration/elmah/errorMail/@password"
Value="[EMAIL_PASSWORD]" />
Value="[ELMAH_EMAIL_PASSWORD]" />
<util:XmlFile Id="ConnectionString"
Action="setValue"
File="[SnittlistanWebDir]Web.config"
Expand Down
23 changes: 23 additions & 0 deletions SnittlistanInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ $emailPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR(
(ConvertTo-SecureString (Get-Content ..\email-password.txt))))

if (-not (Test-Path ..\elmah-email-password.txt)) {
Read-Host -AsSecureString "Enter Elmah Email password" | ConvertFrom-SecureString | Out-File ..\elmah-email-password.txt
}

$elmahEmailPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR(
(ConvertTo-SecureString (Get-Content ..\elmah-email-password.txt))))

if (-not (Test-Path ..\db-host.txt)) {
Read-Host -AsSecureString "Enter Database host" | ConvertFrom-SecureString | Out-File ..\db-host.txt
}
Expand Down Expand Up @@ -107,15 +115,30 @@ $dbPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR(
(ConvertTo-SecureString (Get-Content ..\db-password.txt))))

if (-not (Test-Path ..\owner-email.txt)) {
Read-Host "Enter owner email" | Out-File ..\owner-email.txt
}

$ownerEmail = Get-Content ..\owner-email.txt

if (-not (Test-Path ..\bcc-email.txt)) {
Read-Host "Enter bcc email" | Out-File ..\bcc-email.txt
}

$bccEmail = Get-Content ..\bcc-email.txt

$settings = @{
SERVICE_ACCOUNT = $serviceAccount
SERVICE_PASSWORD = $servicePassword
EMAIL_PASSWORD = $emailPassword
ELMAH_EMAIL_PASSWORD = $elmahEmailPassword
DB_HOST = $dbHost
DB_NAME = $dbName
DB_NAME2 = $dbName2
DB_USERNAME = $dbUsername
DB_PASSWORD = $dbPassword
OWNER_EMAIL = $ownerEmail
BCC_EMAIL = $bccEmail
}

$settingsFormatted = ($settings.Keys | % { "$_=$($settings[$_])" }) -join "`n"
Expand Down

0 comments on commit 058c9f6

Please sign in to comment.