Skip to content

Commit 2510a5e

Browse files
authored
Merge pull request #31 from bradymholt/fix/30
Add enableSSL to config; default false locally
2 parents 76b57d9 + e52209b commit 2510a5e

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

api/Services/EmailSender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task SendEmailAsync(string toEmail, string subject, string htmlMess
3636
{
3737
client.UseDefaultCredentials = false;
3838
client.Credentials = new NetworkCredential(this.Options.username, this.Options.password);
39-
client.EnableSsl = true;
39+
client.EnableSsl = this.Options.enableSSL;
4040
await client.SendMailAsync(mailMessage);
4141
}
4242
}

api/Services/EmailSenderOptions.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33

44
namespace aspnetCoreReactTemplate.Services
55
{
6-
public class EmailSenderOptions
6+
public class EmailSenderOptions
7+
{
8+
private string _smtpConfig { get; set; }
9+
public string smtpConfig
710
{
8-
private string _smtpConfig { get; set; }
9-
public string smtpConfig
10-
{
11-
get { return this._smtpConfig; }
12-
set
13-
{
14-
this._smtpConfig = value;
11+
get { return this._smtpConfig; }
12+
set
13+
{
14+
this._smtpConfig = value;
1515

16-
// smtpConfig is in username:password@localhost:1025 format; extract the part
17-
var smtpConfigPartsRegEx = new Regex(@"(.*)\:(.*)@(.+)\:(.+)");
18-
var smtpConfigPartsMatch = smtpConfigPartsRegEx.Match(value);
16+
// smtpConfig is in username:password@localhost:1025 format; extract the part
17+
var smtpConfigPartsRegEx = new Regex(@"(.*)\:(.*)@(.+)\:(.+)");
18+
var smtpConfigPartsMatch = smtpConfigPartsRegEx.Match(value);
1919

20-
this.username = smtpConfigPartsMatch.Groups[1].Value;
21-
this.password = smtpConfigPartsMatch.Groups[2].Value;
22-
this.host = smtpConfigPartsMatch.Groups[3].Value;
23-
this.port = Convert.ToInt32(smtpConfigPartsMatch.Groups[4].Value);
24-
}
25-
}
26-
27-
public string emailFromName { get; set; }
28-
public string emailFromAddress { get; set; }
29-
30-
public string username { get; protected set; }
31-
public string password { get; protected set; }
32-
public string host { get; protected set; }
33-
public int port { get; protected set; }
20+
this.username = smtpConfigPartsMatch.Groups[1].Value;
21+
this.password = smtpConfigPartsMatch.Groups[2].Value;
22+
this.host = smtpConfigPartsMatch.Groups[3].Value;
23+
this.port = Convert.ToInt32(smtpConfigPartsMatch.Groups[4].Value);
24+
}
3425
}
26+
27+
public string emailFromName { get; set; }
28+
public string emailFromAddress { get; set; }
29+
public bool enableSSL { get; set; }
30+
public string username { get; protected set; }
31+
public string password { get; protected set; }
32+
public string host { get; protected set; }
33+
public int port { get; protected set; }
34+
}
3535
}

api/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"email": {
2121
"smtpConfig": ":@localhost:1025",
22+
"enableSSL": false,
2223
"emailFromName": "aspnet-core-react-template",
2324
"emailFromAddress": "[email protected]"
2425
}

ops/group_vars/all

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
database_name: "{{ app_name }}"
33
database_username: "{{ app_name }}"
44
deploy_directory: "/home/{{ deploy_user }}/apps/{{ app_name }}"
5+
email_enable_ssl: true
56
email_from_name: "{{ app_name }}"
67
postgresql_backup_to_s3: false
78
s3_bucket_name: "s3://app.{{ app_name }}"

ops/roles/deploy/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
jwt.key={{jwt_key}}
1616
jwt.issuer="http://{{webserver_name}}/"
1717
email.smtpConfig={{smtp_config}}
18+
email.enableSSL={{email_enable_ssl}}
1819
email.emailFromName={{email_from_name}}
1920
email.emailFromAddress={{email_from_address}}

0 commit comments

Comments
 (0)