Quick Start Guide
Get up and running with Mailhooks in just a few minutes. This guide will walk you through setting up your first domain and receiving emails.
Step 1
Create Your Account
If you haven't already, sign up for a Mailhooks account. You'll get a free tier that includes:
1 domain
Custom email domain
100 emails/month
Receive up to 100 emails
100 API req/min
Generous rate limits
Step 2
Add Your Domain
After logging in, navigate to the Domains section in your dashboard:
- 1 Click "Add Domain"
- 2 Enter your domain name (e.g.,
mail.yourdomain.com) - 3 Copy the DNS records provided
- 4 Add these records to your domain's DNS settings
- 5 Wait for verification (usually takes 5-30 minutes)
Step 3
Create an API Key
- 1 Go to API Keys in your dashboard
- 2 Click "Create API Key"
- 3 Give it a descriptive name like "Production App"
- 4 Copy and securely store the generated key
Step 4
Set Up a Webhook (Recommended)
Webhooks allow you to receive real-time notifications when emails arrive:
- 1 Go to Webhooks in your dashboard
- 2 Click "Create Webhook"
- 3 Enter your endpoint URL (e.g.,
https://your-app.com/api/webhooks/mailhooks) - 4 Select the "email.received" event
- 5 Save your webhook
Example Webhook Handler (Node.js/Express)
const express = require('express');
const app = express();
app.use(express.json());
app.post('/api/webhooks/mailhooks', async (req, res) => {
const { event, data } = req.body;
if (event === 'email.received') {
console.log('New email received!');
console.log('From:', data.from);
console.log('Subject:', data.subject);
// Process the email
await processEmail(data);
}
res.status(200).send('OK');
});
async function processEmail(email) {
// Your email processing logic here
// e.g., save to database, trigger notifications, etc.
}Step 5
Send a Test Email
Once your domain is verified, send a test email to any address at your domain:
Example addresses:
test@mail.yourdomain.comhello@mail.yourdomain.com- Any address will work!
If you set up a webhook, you'll see the request hit your endpoint immediately. You can also retrieve the email via the API:
Using cURL
curl -H "x-api-key: mh_your_api_key_here" \
https://mailhooks.dev/api/v1/emailsUsing TypeScript SDK
const mailhooks = new Mailhooks({
apiKey: 'mh_your_api_key_here'
});
// Get all emails
const emails = await mailhooks.emails.list();
// Get the latest email
const latestEmail = emails.data[0];
console.log('Latest email:', latestEmail.subject);Next Steps
Learn how to retrieve, filter, and manage emails programmatically.
Set up real-time notifications for incoming emails.
Use our type-safe SDK for easier integration and better DX.
✨ Best Practices
Learn how to handle emails efficiently and securely.