fix : test email : more detail
This commit is contained in:
@@ -84,11 +84,52 @@ This endpoint requires **Admin authentication**. Make sure you're authenticated
|
|||||||
|
|
||||||
If the domain is not blocked but emails still aren't arriving:
|
If the domain is not blocked but emails still aren't arriving:
|
||||||
|
|
||||||
1. Check the sender's email server logs
|
### Step 1: Check WildDuck Server Logs
|
||||||
2. Check WildDuck server logs
|
Look for SMTP rejection messages, connection attempts, or errors related to the sender domain:
|
||||||
3. Verify DNS/MX records for both domains
|
```bash
|
||||||
4. Check if there are any forwarding rules
|
# Check WildDuck logs for SMTP rejections
|
||||||
5. Verify the recipient's email quota isn't exceeded
|
grep -i "metixco.ae" /var/log/wildduck/*.log
|
||||||
|
grep -i "r.sadat@humapek.co" /var/log/wildduck/*.log
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 2: Verify DNS/MX Records
|
||||||
|
Check that the recipient domain has correct MX records:
|
||||||
|
```bash
|
||||||
|
dig MX humapek.co
|
||||||
|
nslookup -type=MX humapek.co
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 3: Check Sender's Email Server
|
||||||
|
Ask the sender to:
|
||||||
|
- Check their email server logs for delivery attempts
|
||||||
|
- Look for bounce messages or error codes
|
||||||
|
- Verify the email address is correct: `r.sadat@humapek.co`
|
||||||
|
|
||||||
|
### Step 4: Verify SPF/DKIM/DMARC Records
|
||||||
|
Check email authentication records:
|
||||||
|
```bash
|
||||||
|
# Check SPF record for sender domain
|
||||||
|
dig TXT metixco.ae | grep -i spf
|
||||||
|
|
||||||
|
# Check DMARC record
|
||||||
|
dig TXT _dmarc.metixco.ae
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 5: Test with Allowlist
|
||||||
|
Try adding the domain to allowlist as a test:
|
||||||
|
```bash
|
||||||
|
POST /email-blocking/allowlist
|
||||||
|
{
|
||||||
|
"recipientEmail": "r.sadat@humapek.co",
|
||||||
|
"senderDomain": "metixco.ae",
|
||||||
|
"description": "Test allowlist for troubleshooting"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 6: Check Firewall/Network
|
||||||
|
- Verify sender's IP is not blocked by firewall
|
||||||
|
- Check if there are any network-level restrictions
|
||||||
|
- Ensure SMTP port (usually 25, 587, or 465) is open
|
||||||
|
|
||||||
## Example: Fix the Current Issue
|
## Example: Fix the Current Issue
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Controller, Get, Query } from "@nestjs/common";
|
import { Body, Controller, Get, Post, Query } from "@nestjs/common";
|
||||||
import { ApiOperation, ApiResponse } from "@nestjs/swagger";
|
import { ApiOperation, ApiResponse } from "@nestjs/swagger";
|
||||||
|
|
||||||
import { EmailSpamService } from "./services/email-spam.service";
|
import { EmailSpamService } from "./services/email-spam.service";
|
||||||
@@ -28,4 +28,26 @@ export class EmailBlockingController {
|
|||||||
const shouldUnblock = unblock === "true" || unblock === "1";
|
const shouldUnblock = unblock === "true" || unblock === "1";
|
||||||
return this.emailSpamService.diagnoseEmailBlocking(recipientEmail, senderDomain, shouldUnblock);
|
return this.emailSpamService.diagnoseEmailBlocking(recipientEmail, senderDomain, shouldUnblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post("allowlist")
|
||||||
|
@AdminRoute()
|
||||||
|
@ApiOperation({
|
||||||
|
summary: "Add domain to allowlist (Admin only)",
|
||||||
|
description: "Add a sender domain to the allowlist for a recipient's business",
|
||||||
|
})
|
||||||
|
@ApiResponse({ status: 200, description: "Domain added to allowlist" })
|
||||||
|
@ApiResponse({ status: 400, description: "Invalid parameters" })
|
||||||
|
@ApiResponse({ status: 403, description: "Not authorized (Admin only)" })
|
||||||
|
async addToAllowlist(
|
||||||
|
@Body() body: { recipientEmail: string; senderDomain: string; description?: string },
|
||||||
|
) {
|
||||||
|
if (!body.recipientEmail || !body.senderDomain) {
|
||||||
|
throw new Error("Both recipientEmail and senderDomain are required");
|
||||||
|
}
|
||||||
|
return this.emailSpamService.addDomainToAllowlistForUser(
|
||||||
|
body.recipientEmail,
|
||||||
|
body.senderDomain,
|
||||||
|
body.description,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,4 +508,39 @@ export class EmailSpamService {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==============================================
|
||||||
|
/**
|
||||||
|
* Add domain to allowlist for a specific user's business
|
||||||
|
*/
|
||||||
|
async addDomainToAllowlistForUser(recipientEmail: string, senderDomain: string, description?: string) {
|
||||||
|
this.logger.log(`Adding domain ${senderDomain} to allowlist for user ${recipientEmail}`);
|
||||||
|
|
||||||
|
// Find user by email
|
||||||
|
const user = await this.userRepository.findOne({ emailAddress: recipientEmail, deletedAt: null }, { populate: ["business"] });
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
throw new Error(`User with email ${recipientEmail} not found`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const domainTag = user.business?.id || "default";
|
||||||
|
const finalDescription = description || `Manually allowlisted for ${recipientEmail}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await this.addDomainToAllowlist(senderDomain, finalDescription, domainTag);
|
||||||
|
this.logger.log(`Successfully added ${senderDomain} to allowlist for domain tag: ${domainTag}`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Domain ${senderDomain} has been added to allowlist for ${recipientEmail}`,
|
||||||
|
domainTag,
|
||||||
|
domain: senderDomain,
|
||||||
|
description: finalDescription,
|
||||||
|
result,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(`Failed to add domain to allowlist: ${error instanceof Error ? error.message : "Unknown error"}`);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user