Skip to content

Commit 68ae64c

Browse files
committed
fix: format doc
1 parent 1779a4f commit 68ae64c

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

docs/Features/email-config.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Email Service Configuration
22

33
The MailService provides email functionality using SMTP protocol. It supports:
4+
45
- Account activation emails
56
- Password reset emails
67
- Welcome emails
@@ -31,12 +32,16 @@ Configure email settings in `appsettings.json`:
3132
```
3233

3334
#### Development Configuration
35+
3436
For local development, you can use:
37+
3538
- [MailHog](https://github.com/mailhog/MailHog) - Recommended for Mac/Linux
3639
- [Papercut SMTP](https://github.com/ChangemakerStudios/Papercut-SMTP) - Windows alternative
3740

3841
#### Production Configuration
42+
3943
Common SMTP providers:
44+
4045
- Gmail SMTP:
4146
```json
4247
"Smtp": {
@@ -57,6 +62,7 @@ Common SMTP providers:
5762
### Usage Examples
5863

5964
1. Activation Email:
65+
6066
```csharp
6167
await _mailService.SendActivationEmail(
6268
@@ -66,6 +72,7 @@ await _mailService.SendActivationEmail(
6672
```
6773

6874
2. Password Reset:
75+
6976
```csharp
7077
await _mailService.SendPasswordResetMail(
7178
@@ -75,6 +82,7 @@ await _mailService.SendPasswordResetMail(
7582
```
7683

7784
3. Welcome Email:
85+
7886
```csharp
7987
await _mailService.SendCreationEmail(
8088
@@ -85,6 +93,7 @@ await _mailService.SendCreationEmail(
8593
### Security Best Practices
8694

8795
1. **SMTP Security**
96+
8897
- Enable TLS/SSL encryption (`UseSsl: true`)
8998
- Use environment variables for credentials:
9099
```json
@@ -95,6 +104,7 @@ await _mailService.SendCreationEmail(
95104
- Use dedicated sending domains
96105

97106
2. **Content Security**
107+
98108
- Sanitize all user input in templates
99109
- Include SPF/DKIM records for your domain
100110
- Set up DMARC policy
@@ -108,16 +118,17 @@ await _mailService.SendCreationEmail(
108118
### Testing
109119

110120
1. Unit Testing:
121+
111122
```csharp
112123
[Fact]
113124
public async Task Should_Send_Activation_Email()
114125
{
115126
// Arrange
116127
var mockMailService = new Mock<IMailService>();
117-
128+
118129
// Act
119130
await mailService.SendActivationEmail("[email protected]", "Test User", "key123");
120-
131+
121132
// Assert
122133
mockMailService.Verify(x => x.SendActivationEmail(
123134
It.IsAny<string>(),
@@ -128,12 +139,13 @@ public async Task Should_Send_Activation_Email()
128139
```
129140

130141
2. Integration Testing:
142+
131143
```csharp
132144
[Fact]
133145
public async Task Should_Connect_To_SMTP_Server()
134146
{
135147
// Use MailHog for integration tests
136-
var mailConfig = new MailConfiguration
148+
var mailConfig = new MailConfiguration
137149
{
138150
Host = "localhost",
139151
Port = 1025
@@ -147,8 +159,8 @@ public async Task Should_Connect_To_SMTP_Server()
147159
- Verify network connectivity to SMTP server
148160
- Check firewall rules for SMTP ports (25, 465, 587)
149161
- Validate SSL certificate if using TLS
150-
151162
2. **Authentication Problems**
163+
152164
- Ensure credentials are correctly encoded
153165
- Check for IP-based restrictions
154166
- Verify OAuth2 settings if applicable
@@ -173,4 +185,4 @@ public async Task Should_Connect_To_SMTP_Server()
173185

174186
- [JHipster Email Configuration Guide](https://www.jhipster.tech/tips/011_tip_configuring_email_in_jhipster.html)
175187
- [MailKit Documentation](https://github.com/jstedfast/MailKit#documentation)
176-
- [SMTP Security Best Practices](https://www.m3aawg.org/published-documents)
188+
- [SMTP Security Best Practices](https://www.m3aawg.org/published-documents)

0 commit comments

Comments
 (0)