Configure your email database
Mailpipe uses Supabase as your email database. This guide walks you through creating a Supabase project and connecting it to Mailpipe.
If you don't already have a Supabase project, create one at supabase.com. Choose a region close to your users for best performance.
Important: Make sure to save your database password during project creation. You'll need it later.
In your Supabase dashboard, navigate to Project Settings -> API to find your credentials:
In your Mailpipe dashboard, go to Settings -> Database and enter your Supabase credentials:
SUPABASE_URL=https://your-project.supabase.co SUPABASE_ANON_KEY=eyJhbGci... SUPABASE_SERVICE_ROLE_KEY=eyJhbGci...
Mailpipe will automatically create the required tables when you first connect. The following tables will be created:
-- Core tables created by Mailpipe CREATE TABLE emails ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), mailbox_id UUID REFERENCES mailboxes(id), from_address TEXT NOT NULL, to_address TEXT NOT NULL, subject TEXT, text_body TEXT, html_body TEXT, headers JSONB, received_at TIMESTAMPTZ DEFAULT NOW(), read BOOLEAN DEFAULT FALSE, starred BOOLEAN DEFAULT FALSE, labels TEXT[] ); CREATE TABLE mailboxes ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name TEXT NOT NULL, address TEXT UNIQUE NOT NULL, domain_id UUID REFERENCES domains(id), created_at TIMESTAMPTZ DEFAULT NOW() ); CREATE TABLE routing_rules ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name TEXT NOT NULL, priority INTEGER DEFAULT 0, conditions JSONB NOT NULL, actions JSONB NOT NULL, enabled BOOLEAN DEFAULT TRUE );
For production use, we strongly recommend enabling Row Level Security. Mailpipe creates default RLS policies that ensure users can only access their own data:
-- Enable RLS on all tables
ALTER TABLE emails ENABLE ROW LEVEL SECURITY;
ALTER TABLE mailboxes ENABLE ROW LEVEL SECURITY;
ALTER TABLE routing_rules ENABLE ROW LEVEL SECURITY;
-- Example policy: Users can only see emails from their mailboxes
CREATE POLICY "Users can view own emails" ON emails
FOR SELECT
USING (
mailbox_id IN (
SELECT id FROM mailboxes
WHERE user_id = auth.uid()
)
);To get instant email notifications and live updates in the Mailpipe UI, enable real-time on the emails table:
-- In Supabase Dashboard: Database > Replication -- Or via SQL: ALTER PUBLICATION supabase_realtime ADD TABLE emails;
If you're having trouble connecting, verify that:
If migrations fail, check that your service role key has the necessary permissions. The service role key should have full access to create tables and policies.
Now that your database is set up, configure your email provider to start receiving emails.