Postgres Smtp Email Queue That Prevents Duplicate Sends

    What this workflow does

    The workflow contains these steps: Run Once to Create Tables → Create Outbox Tables → Enqueue Email Webhook → Every Minute → Daily Summary at 8am → Outbox Settings → Which Trigger? → Validate Email Request → Request Valid? → Enqueue Once → Enqueue Result → Respond Queued → Respond Duplicate → Respond Address Blocked → Respond Database Unavailable → Respond Invalid Request → Mark Stuck and Blocked Emails → New Stuck Emails? → Alert Owner About Stuck Emails → Claim Due Emails → Any Emails Claimed? → Send Queued Email → Mark Email Sent → Classify SMTP Error → Record Send Failure → Count Last 24 Hours → Email Daily Summary.

    What you need

    • An n8n instance to import and run the workflow.
    • StickyNote access for the StickyNote steps listed in this workflow.
    • ManualTrigger access for the ManualTrigger steps listed in this workflow.
    • Postgres access for the Postgres steps listed in this workflow.
    • Webhook access for the Webhook steps listed in this workflow.
    • Schedule access for the Schedule steps listed in this workflow.
    • Set access for the Set steps listed in this workflow.
    • Switch access for the Switch steps listed in this workflow.
    • Code access for the Code steps listed in this workflow.
    • IF access for the IF steps listed in this workflow.
    • RespondToWebhook access for the RespondToWebhook steps listed in this workflow.
    • EmailSend access for the EmailSend steps listed in this workflow.

    Workflow nodes

    1. Run Once to Create Tables (n8n-nodes-base.manualTrigger)
    2. Create Outbox Tables (n8n-nodes-base.postgres)
    3. Enqueue Email Webhook (n8n-nodes-base.webhook)
    4. Every Minute (n8n-nodes-base.scheduleTrigger)
    5. Daily Summary at 8am (n8n-nodes-base.scheduleTrigger)
    6. Outbox Settings (n8n-nodes-base.set)
    7. Which Trigger? (n8n-nodes-base.switch)
    8. Validate Email Request (n8n-nodes-base.code)
    9. Request Valid? (n8n-nodes-base.if)
    10. Enqueue Once (n8n-nodes-base.postgres)
    11. Enqueue Result (n8n-nodes-base.switch)
    12. Respond Queued (n8n-nodes-base.respondToWebhook)
    13. Respond Duplicate (n8n-nodes-base.respondToWebhook)
    14. Respond Address Blocked (n8n-nodes-base.respondToWebhook)
    15. Respond Database Unavailable (n8n-nodes-base.respondToWebhook)
    16. Respond Invalid Request (n8n-nodes-base.respondToWebhook)
    17. Mark Stuck and Blocked Emails (n8n-nodes-base.postgres)
    18. New Stuck Emails? (n8n-nodes-base.if)
    19. Alert Owner About Stuck Emails (n8n-nodes-base.emailSend)
    20. Claim Due Emails (n8n-nodes-base.postgres)
    21. Any Emails Claimed? (n8n-nodes-base.if)
    22. Send Queued Email (n8n-nodes-base.emailSend)
    23. Mark Email Sent (n8n-nodes-base.postgres)
    24. Classify SMTP Error (n8n-nodes-base.code)
    25. Record Send Failure (n8n-nodes-base.postgres)
    26. Count Last 24 Hours (n8n-nodes-base.postgres)
    27. Email Daily Summary (n8n-nodes-base.emailSend)
    StickyNoteManualTriggerPostgresWebhookScheduleSetSwitchCodeIFRespondToWebhookEmailSend
    33 nodesData Processing
    View on GitHub

    Need this workflow customized or debugged? Book a 30-min scope call →

    Want this set up for you? Book a 30-min scope call

    I build and fix n8n workflows for agencies and SaaS teams. 30-minute scope call — bring the problem, leave with an estimate.

    Related workflows