In today’s world, newsletters are more than just marketing tools — they’re often rich sources of niche content, curated industry insights, or competitive intel. But extracting that information manually from your inbox can be tedious and error-prone. That’s where newsletter scraping comes into play.
Whether you're building a content aggregator, monitoring competitors, or simply want to archive specific types of emails for later analysis, having a structured, automated way to capture newsletter content can save hours of work.
deliverhook makes this process dead simple. Instead of polling an inbox or setting up a complex email parser, you can just receive emails directly via a webhook – clean, structured, and ready to process.
In this article, we’ll show you how to use deliverhook together with Node.js and MariaDB to:
At its core, deliverhook acts like a virtual inbox that instantly transforms incoming emails into structured webhook payloads. Instead of managing your own mail server or polling an IMAP inbox, you define a custom email address and link it to a webhook endpoint. From that point on, every incoming email is automatically forwarded to your backend in real-time — as clean JSON.
Here’s how the flow looks in practice:
To get started, we’ll need a few basic components:
First, initialize a new Node.js project (if you haven't already) and install express
by typing the following commands into your terminal:
npm init -y
npm install express
Then, set up a basic Express server that can receive webhook POST requests from deliverhook:
import express from 'express';
const app = express();
app.use(express.json());
app.post('/webhook/newsletters', async (req, res) => {
const { from, subject, text, html } = req.body;
console.log('Received newsletter:', { from, subject });
// Save to database (we’ll get to that next)
res.status(200).send('Received');
});
app.listen(3000, () => {
console.log('Webhook server listening on port 3000');
});
You can now link this endpoint to your deliverhook inbox via the dashboard.
Next, let’s define a simple MariaDB table to store incoming newsletters:
CREATE TABLE newsletters (
id INT AUTO_INCREMENT PRIMARY KEY,
sender VARCHAR(255),
subject TEXT,
text_content MEDIUMTEXT,
html_content MEDIUMTEXT,
received_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
We’ll insert into this table from our webhook handler in the next step.
To store incoming newsletters in your MariaDB database, you’ll need to install the mysql2
package and establish a connection from your Node.js app.
npm install mysql2
Then, update your webhook handler to insert the parsed data into the database:
import express from 'express';
import mysql from 'mysql2/promise';
const app = express();
app.use(express.json());
// Setup database connection
const db = await mysql.createConnection({
host: 'localhost',
user: 'your_db_user',
password: 'your_db_password',
database: 'your_db_name',
});
app.post('/webhook/newsletters', async (req, res) => {
const { from, subject, text, html } = req.body;
try {
await db.execute(
'INSERT INTO newsletters (sender, subject, text_content, html_content) VALUES (?, ?, ?, ?)',
[from, subject, text, html]
);
res.status(200).send('Saved to DB');
} catch (err) {
console.error('Database error:', err);
res.status(500).send('Failed to save');
}
});
app.listen(3000, () => {
console.log('Webhook server listening on port 3000');
});
Now, make sure to configure this webhook endpoint in your deliverhook dashboard. Go to your inbox settings and set the webhook URL to:
http://your-server.com/webhook/newsletters
Once configured, every incoming email to your deliverhook address will trigger this endpoint and store the newsletter in your database.
Register now, to receive emails to your webhook endpoints
Signup now - 100% free