Skip to main content
Receiving emails from external sources introduces security considerations. This guide covers best practices for securing your inbound email processing pipeline.

Webhook Security

Verify Webhook Credentials

Always verify that webhooks come from Lettr, not malicious actors. Lettr supports Basic Auth and OAuth 2.0 for webhook authentication — configure your preferred method when creating the webhook in the dashboard.
See Webhook Authorization for details on configuring Basic Auth and OAuth 2.0.

IP Allowlisting

You can optionally restrict webhook access to known IP addresses as an additional layer of defense:
IP allowlisting should be used as a supplementary security measure alongside credential verification, not as a replacement.

Input Validation

Validate Email Addresses

Never trust email addresses from inbound emails:

Sanitize Email Content

Sanitize HTML content before displaying or storing:

Validate and Sanitize Filenames

Never use attachment filenames directly:

Attachment Security

Validate File Types

Never trust the declared content type:

Scan for Malware

Integrate with a virus scanner:

Limit File Sizes

Enforce size limits to prevent resource exhaustion:

Content Security

Prevent XSS in Displayed Emails

When displaying email content in a web interface:

Block Tracking Pixels

Strip tracking pixels from received emails:

Rate Limiting

Protect against email flooding:

Logging and Monitoring

Audit Logging

Log all inbound email processing:

Anomaly Detection

Monitor for suspicious patterns:

Security Checklist

  • Verify webhook credentials (Basic Auth or OAuth 2.0) on every request
  • Store credentials securely in environment variables
  • Use HTTPS for your webhook endpoint
  • Consider IP allowlisting as additional protection
  • Validate all email addresses
  • Sanitize HTML content before storage/display
  • Sanitize filenames before use
  • Validate attachment content types
  • Verify file types from content, not headers
  • Scan attachments for malware
  • Enforce size limits
  • Store attachments outside web root
  • Log all inbound email processing
  • Monitor for rate limit violations
  • Alert on anomalous patterns
  • Track spam score distributions
Never trust any data from inbound emails. Senders can forge headers, spoof addresses, and include malicious content. Always validate and sanitize everything.

Webhook Authorization

Secure webhook endpoints

Spam Filtering

Filter spam emails

Attachments

Handle attachments safely

Best Practices

Overall best practices