A high-performance Node.js DNS lookup service that provides comprehensive email security and domain validation capabilities. Built specifically for webmail applications with support for BIMI, SPF, DKIM, DMARC, and MX record queries.
- π₯οΈ WebMail UI: github.com/Yukthi-Systems/WebMail-UI
- π¬ Discord: discord.gg/29zTxvque
- BIMI Record Lookup - Brand Indicators for Message Identification
- SPF Record Query - Sender Policy Framework validation
- DKIM Record Lookup - DomainKeys Identified Mail verification
- DMARC Policy Check - Domain-based Message Authentication
- MX Record Resolution - Mail server discovery
- Domain Validation - Comprehensive validation of all DNS records
- Node.js >= 18.0.0
- npm >= 8.0.0
-
Clone the repository
git clone https://github.com/Yukthi-Systems/WebMail-BIMI-API cd WebMail-BIMI-API -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Build the project
npm run build
Development Mode:
npm run devProduction Mode:
npm startThe API will be available at http://localhost:3001
http://localhost:3001/api/dns
GET /healthReturns server health status and uptime information.
GET /api/dns/bimi?domain=example.comRetrieves BIMI (Brand Indicators for Message Identification) records.
GET /api/dns/spf?domain=example.comQueries SPF (Sender Policy Framework) records for email authentication.
GET /api/dns/dkim?domain=example.com&selector=mailsvcLooks up DKIM public keys. The selector parameter is optional and defaults to mailsvc.
GET /api/dns/dmarc?domain=example.comRetrieves DMARC (Domain-based Message Authentication) policy records.
GET /api/dns/mx?domain=example.comResolves MX (Mail Exchange) records sorted by priority.
GET /api/dns/validate?domain=example.com&selector=mailsvcPerforms comprehensive validation of all DNS records in a single request. Returns:
- MX, SPF, DKIM, DMARC, and BIMI record status
- Validation score (0-100%)
- Detailed results for each record type
- Summary of passed/failed checks
The API supports multi-tenant branding based on a unique slug. This allows serving specific logos and backgrounds for different companies/instances.
GET /api/dns/company-config/:slug?Returns the full branding configuration (slug, domains, asset mappings, theme) for a given slug or domain.
GET /api/dns/logo-image/:slug?
GET /api/dns/bg-image/:slug?Serves the specific logo or background image for a company.
- Slug: Path parameter (e.g.,
/logo-image/example) - Domain Fallback: Query parameter (e.g.,
/logo-image?domain=example.com) - Dark Mode: Supports
?mode=darkquery parameter.
POST /api/dns/update-companyUnified endpoint to update company details and upload assets in a single request.
Form Data Fields:
slug(Required): Unique identifier for the company.name(Optional): Display name.domains(Optional): Comma-separated list of domains.logo: Image file.background: Image file.logoDark: Image file for dark mode.backgroundDark: Image file for dark mode.
All endpoints return responses in the following format:
{
"success": true,
"data": {
// Response data specific to the endpoint
},
"timestamp": 1703123456789
}{
"success": false,
"error": "DNS query failed",
"message": "Domain not found",
"timestamp": 1703123456789
}Create a .env file with the following variables:
# Server Configuration
PORT=3001
NODE_ENV=development
# CORS Configuration
CORS_ORIGIN=http://localhost:3000,http://localhost:5173
# Branding & Assets Configuration
DOMAIN_IMAGES_PATH=/data/images
COMPANIES_CONFIG_PATH=/data/config/companies.jsonTo ensure your configurations and images survive container restarts, map a volume to /data:
services:
dns-lookup-api:
# ...
volumes:
- ./data:/dataThe service uses reliable public DNS servers:
- Google DNS: 8.8.8.8, 8.8.4.4
- Cloudflare DNS: 1.1.1.1
- Default Limit: 100 requests per minute per IP address
- Response: HTTP 429 when limit exceeded
- Reset: Automatically resets every minute
src/
βββ controller/ # Request handlers
β βββ dns.ts # DNS lookup controllers
βββ middleware/ # Express middleware
β βββ rateLimiter.ts # Rate limiting logic
β βββ validations.ts # Input validation
βββ routes/ # API route definitions
β βββ dns.ts # DNS routes
βββ types/ # TypeScript type definitions
β βββ dns.ts # DNS-related types
βββ utils/ # Utility functions
β βββ logger.ts # File logging system
βββ app.ts # Express app configuration
βββ server.ts # Server entry point
- Helmet.js: Security headers
- CORS: Cross-origin resource sharing protection
- Input Validation: Domain format validation
- Rate Limiting: Request throttling per IP
- Error Sanitization: No sensitive data in error responses
Basic SPF lookup:
curl "http://localhost:3001/api/dns/spf?domain=gmail.com"DKIM with custom selector:
curl "http://localhost:3001/api/dns/dkim?domain=gmail.com&selector=20230601"Comprehensive domain validation:
curl "http://localhost:3001/api/dns/validate?domain=example.com"- Default:
mailsvc(configurable) - Common selectors:
default,selector1,google,microsoft - Format:
[selector]._domainkey.[domain]
- SPF: TXT record at domain root
- DMARC: TXT record at
_dmarc.[domain] - DKIM: TXT record at
[selector]._domainkey.[domain] - BIMI: TXT record at
default._bimi.[domain] - MX: MX record at domain root
The API handles various DNS errors gracefully:
- ENOTFOUND: Domain not found
- ENODATA: No DNS records found
- Timeout: DNS query timeout (5 second limit)
- Invalid Format: Malformed domain names
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Create a Pull Request
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.