All Modules

SQL Send

Database Messaging

Send emails and SMS directly from SQL Server and PostgreSQL via SendGrid, Resend, and Twilio. Transactional outbox pattern ensures guaranteed delivery with no lost messages.

Supported Providers

šŸ“§

SendGrid

Email

āœ‰ļø

Resend

Email

šŸ“±

Twilio

SMS

šŸ”§

Custom SMTP

Email

Transactional Outbox Pattern

Messages are written to an outbox table in the same transaction as your data changes. No messages are ever lost, even during failures.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  1. Application Transaction                                      │
│  ─────────────────────────────────────────────────────────────  │
│  BEGIN TRANSACTION                                               │
│    INSERT INTO Orders (CustomerId, Total) VALUES (1, 99.99);    │
│    INSERT INTO sql2ai.Outbox (Type, Payload) VALUES             │
│      ('order_confirmation', '{"orderId": 123, "email": "..."}');│
│  COMMIT                                                          │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                            │
                            ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  2. SQL Send Agent (polls Outbox)                                │
│  ─────────────────────────────────────────────────────────────  │
│  • Reads pending messages                                        │
│  • Sends via configured provider                                 │
│  • Marks as sent (or retries on failure)                        │
│  • Moves to archive after success                                │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                            │
                            ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  3. Provider Delivery                                            │
│  ─────────────────────────────────────────────────────────────  │
│  SendGrid / Resend / Twilio → Customer                          │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Simple SQL Interface

-- Send an email
EXEC sql2ai.SendEmail
    @To = 'customer@example.com',
    @Subject = 'Order Confirmation',
    @Body = '<h1>Thank you for your order!</h1>',
    @Provider = 'sendgrid';  -- or 'resend'

-- Send an SMS
EXEC sql2ai.SendSMS
    @To = '+1234567890',
    @Message = 'Your order has shipped!',
    @Provider = 'twilio';

-- Send with template
EXEC sql2ai.SendEmail
    @To = 'customer@example.com',
    @Template = 'order_confirmation',
    @TemplateData = '{"orderId": 12345, "total": 99.99}';

-- Bulk send (queued efficiently)
EXEC sql2ai.SendBulkEmail
    @Recipients = '[
        {"email": "a@x.com", "data": {"name": "Alice"}},
        {"email": "b@x.com", "data": {"name": "Bob"}}
    ]',
    @Template = 'newsletter';

Features

Guaranteed Delivery

Outbox pattern ensures no messages are ever lost

Retry Logic

Automatic retries with exponential backoff

Template Engine

Handlebars templates with data binding

Tracking

Delivery status, opens, clicks tracked

Rate Limiting

Respect provider rate limits automatically

Audit Trail

Complete history of all sent messages

Delivery Dashboard

╔══════════════════════════════════════════════════════════════════╗
ā•‘                    SQL SEND DASHBOARD                             ā•‘
╠══════════════════════════════════════════════════════════════════╣
ā•‘ LAST 24 HOURS                                                     ā•‘
ā•‘ ─────────────────────────────────────────────────────────────── ā•‘
ā•‘ Emails Sent:      12,847                                          ā•‘
ā•‘ SMS Sent:         1,234                                           ā•‘
ā•‘ Delivery Rate:    99.7%                                           ā•‘
ā•‘ Open Rate:        34.2%                                           ā•‘
╠══════════════════════════════════════════════════════════════════╣
ā•‘ OUTBOX STATUS                                                     ā•‘
ā•‘ ─────────────────────────────────────────────────────────────── ā•‘
ā•‘ Pending:          23                                              ā•‘
ā•‘ Processing:       5                                               ā•‘
ā•‘ Retry Queue:      2 (next retry in 5 min)                        ā•‘
ā•‘ Failed (24h):     4                                               ā•‘
╠══════════════════════════════════════════════════════════════════╣
ā•‘ BY PROVIDER                                                       ā•‘
ā•‘ ─────────────────────────────────────────────────────────────── ā•‘
ā•‘ SendGrid:         10,234 emails | 99.8% delivered                ā•‘
ā•‘ Resend:           2,613 emails  | 99.5% delivered                ā•‘
ā•‘ Twilio:           1,234 SMS     | 99.9% delivered                ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•

Send Messages Reliably

Email and SMS from your database with guaranteed delivery and full tracking.

No credit card required • Free for individual developers