1- # InboundParse - Enhanced Email to Webhook Gateway
1+ # InboundParse - Email to Webhook Gateway
22
33A modern SMTP server that receives emails from any domain without authentication and forwards them to webhooks with comprehensive email authentication validation and SSL/TLS support.
44
55## Features
66
7- - ** No Authentication Required** : Accepts emails from any domain without username/password
8- - ** SSL/ TLS Support** : Automatic SSL certificate management via Let's Encrypt
7+ - ** No SMTP Auth Required** : Accepts emails from any domain without username/password
8+ - ** TLS Support** : Optional TLS when ` -cert-file ` and ` -key-file ` are provided
99- ** SPF Validation** : Validates Sender Policy Framework records
10- - ** DKIM Validation** : Verifies DomainKeys Identified Mail signatures
11- - ** DMARC Validation** : Checks Domain-based Message Authentication, Reporting & Conformance policies
12- - ** Complete Headers** : Includes all email headers in the webhook payload
10+ - ** DKIM Validation** : Verifies DomainKeys Identified Mail signatures
11+ - ** DMARC Validation** : Evaluates DMARC policy and alignment
12+ - ** Headers Included ** : Forwards received headers along with parsed message data
1313- ** Webhook Authentication** : Supports HTTP Basic Auth for webhook endpoints
14- - ** Comprehensive Logging** : Detailed logging with verbose mode option
15- - ** Multiple Ports** : Supports both port 25 (SMTP) and 587 (submission)
14+ - ** Verbose Logging** : Enable extra logs with ` -verbose `
15+ - ** Multiple Ports** : Listens on 25 by default; TLS listener on 587 when certs are provided
16+ - ** PROXY protocol** : Accepts PROXY protocol connections (e.g., from load balancers)
1617
1718## Quick Start
1819
@@ -34,15 +35,17 @@ go build -o inboundparse
3435``` bash
3536Usage of ./inboundparse:
3637 -listen string
37- SMTP server listen address (default " :25" )
38+ SMTP server listen address (default " 0.0.0.0:25" )
39+ -listen-tls string
40+ SMTP server listen address for TLS (default " 0.0.0.0:587" )
3841 -webhook string
3942 Webhook URL to send email data to (required)
4043 -webhook-user string
4144 Basic auth username for webhook
4245 -webhook-pass string
4346 Basic auth password for webhook
4447 -name string
45- SMTP server name (default " inboundparse" )
48+ SMTP server name (default " mx. inboundparse.com " )
4649 -max-size int
4750 Maximum message size in bytes (default 10485760)
4851 -read-timeout int
@@ -56,9 +59,9 @@ Usage of ./inboundparse:
5659 -enable-dmarc
5760 Enable DMARC validation (default true)
5861 -cert-file string
59- SSL certificate file path
62+ TLS certificate file path (optional)
6063 -key-file string
61- SSL private key file path
64+ TLS private key file path (optional)
6265 -verbose
6366 Enable verbose logging (default false)
6467```
@@ -71,19 +74,12 @@ You can also configure using environment variables:
7174- ` WEBHOOK_URL ` - Webhook URL (required)
7275- ` WEBHOOK_USER ` - Basic auth username for webhook
7376- ` WEBHOOK_PASS ` - Basic auth password for webhook
74- - ` LISTEN_ADDR ` - SMTP server listen address
75- - ` SERVER_NAME ` - SMTP server name
77+ - ` LISTEN_ADDR ` - SMTP server listen address (overrides ` -listen ` )
78+ - ` LISTEN_ADDR_TLS ` - TLS server listen address (overrides ` -listen-tls ` )
7679
77- #### SSL/TLS Configuration
78- - ` MXDOMAIN ` - Domain name for SSL certificates (required for SSL)
79- - ` CERT_FILE ` - SSL certificate file path (default: /cert/cert.pem)
80- - ` KEY_FILE ` - SSL private key file path (default: /cert/key.pem)
81-
82- #### Let's Encrypt Configuration
83- - ` CF_Token ` - Cloudflare API token for DNS validation
84- - ` CF_Zone_ID ` - Cloudflare zone ID
85- - ` DNS_API ` - DNS API provider (default: dns_cf)
86- - ` ACME_SH_EMAIL ` - Email for Let's Encrypt account registration
80+ #### TLS Configuration
81+ - ` CERT_FILE ` - TLS certificate file path
82+ - ` KEY_FILE ` - TLS private key file path
8783
8884#### Feature Toggles
8985- ` ENABLE_SPF ` - Enable SPF validation (default: true)
@@ -93,59 +89,25 @@ You can also configure using environment variables:
9389
9490## Webhook Payload
9591
96- The service sends a JSON payload to your webhook with the following structure :
92+ The service sends a JSON payload to your webhook similar to :
9793
9894``` json
9995{
10096 "timestamp" : " 2024-01-01T12:00:00Z" ,
101- "from" : {
102- "address" : " sender@example.com" ,
103- "name" : " Sender Name"
104- },
105- "to" : [
106- {
107- "address" : " recipient1@example.com" ,
108- "name" : " Recipient 1"
109- },
110- {
111- "address" : " recipient2@example.com" ,
112- "name" : " Recipient 2"
113- }
114- ],
97+ "from" : [{ "address" : " sender@example.com" , "name" : " Sender" }],
98+ "to" : [{ "address" : " recipient@example.com" , "name" : " Recipient" }],
11599 "subject" : " Email Subject" ,
116100 "message_id" : " <unique-message-id@example.com>" ,
117- "headers" : {
118- "From" : [" sender@example.com" ],
119- "To" : [" recipient1@example.com" , " recipient2@example.com" ],
120- "Subject" : [" Email Subject" ],
121- "Date" : [" Mon, 1 Jan 2024 12:00:00 +0000" ],
122- "Message-ID" : [" <unique-message-id@example.com>" ],
123- "Content-Type" : [" text/plain; charset=utf-8" ]
124- },
125- "text_body" : " Plain text email body content" ,
126- "html_body" : " HTML email body content" ,
101+ "headers" : { "From" : [" sender@example.com" ], "Subject" : [" Email Subject" ] },
102+ "text_body" : " Plain text body" ,
103+ "enriched_text_body" : " ..." ,
104+ "html_body" : " <p>HTML body</p>" ,
105+ "attachments" : [ /* array of files */ ],
106+ "inline_files" : [ /* array of inline files */ ],
127107 "authentication_results" : {
128- "spf" : {
129- "result" : " pass" ,
130- "raw" : " SPF result: pass for domain example.com from IP 192.168.1.100" ,
131- "mechanism" : " include:_spf.example.com"
132- },
133- "dkim" : {
134- "valid" : true ,
135- "signatures" : [" Valid: example.com" ],
136- "raw" : " DKIM verification found 1 signatures"
137- },
138- "dmarc" : {
139- "result" : " pass" ,
140- "raw" : " DMARC record found for domain example.com" ,
141- "policy" : " quarantine"
142- }
143- },
144- "raw" : " Full raw email message including headers and body" ,
145- "server_info" : {
146- "remote_addr" : " 192.168.1.100:54321" ,
147- "local_addr" : " 0.0.0.0:25" ,
148- "server_name" : " inboundparse"
108+ "spf" : { "result" : " pass" , "raw" : " ..." , "mechanism" : " ..." },
109+ "dkim" : { "valid" : true , "signatures" : [" Valid: example.com" ], "raw" : " ..." },
110+ "dmarc" : { "result" : " pass" , "raw" : " ..." , "policy" : " reject" }
149111 }
150112}
151113```
@@ -185,41 +147,26 @@ docker run -p 25:25 -p 587:587 inboundparse \
185147 -verbose=true
186148```
187149
188- ### Run with Docker (SSL/ TLS)
150+ ### Run with Docker (TLS)
189151
190- ``` bash
191- docker run -p 25:25 -p 587:587 \
192- -e WEBHOOK_URL=https://your-webhook-url.com/api/webhook \
193- -e MXDOMAIN=mx.yourdomain.com \
194- -e CF_Token=your-cloudflare-token \
195- -e CF_Zone_ID=your-zone-id \
196- -e ACME_SH_EMAIL=your-email@example.com \
197- -e VERBOSE=true \
198- inboundparse
199- ```
152+ Provide your own certificate and key inside the container and set ` CERT_FILE ` /` KEY_FILE ` .
200153
201154### Environment File (.env)
202155
203- Create a ` .env ` file in your project directory:
156+ Create a ` .env ` file in your project directory (optional) :
204157
205158``` bash
206- # Required
207159WEBHOOK_URL=https://your-webhook-url.com/api/webhook
208- MXDOMAIN=mx.yourdomain.com
209-
210- # Cloudflare DNS API (required for SSL)
211- CF_Token=your-cloudflare-token
212- CF_Zone_ID=your-zone-id
213- DNS_API=dns_cf
214-
215- # SSL Configuration
216- ACME_SH_EMAIL=your-email@example.com
217160
218- # Feature Configuration
161+ # Optional overrides
162+ LISTEN_ADDR=0.0.0.0:25
163+ LISTEN_ADDR_TLS=0.0.0.0:587
219164ENABLE_SPF=true
220165ENABLE_DKIM=true
221166ENABLE_DMARC=true
222- VERBOSE=true
167+ VERBOSE=false
168+ CERT_FILE=/cert/cert.pem
169+ KEY_FILE=/cert/key.pem
223170```
224171
225172## Testing
0 commit comments