Docs Troubleshooting

Debugging

Tips and techniques for debugging email issues in mailshit.

Debugging Approach

When something goes wrong, follow this process:

  1. Identify the symptom - What’s happening?
  2. Check the response - What did the API return?
  3. Isolate the problem - Where does it break?
  4. Test the fix - Verify the solution works

API Response Analysis

Success Response

{
  "success": true,
  "type": "sent",
  "messageId": "msg_abc123"
}

Everything worked. Store messageId for tracking.

Validation Failed

{
  "success": false,
  "type": "validation_failed",
  "error": "Invalid email address",
  "field": "_to"
}

The field tells you exactly what to fix.

Send Failed

{
  "success": false,
  "type": "send_failed",
  "error": "Recipient email is not verified"
}

Check your provider dashboard for more details.

Flow Error

{
  "success": false,
  "type": "flow_error",
  "error": "Template not found in flow graph"
}

Configuration issue in mailshit—check your flow.

Using Callback Output for Debugging

Temporarily switch to callback output to debug rendering:

  1. Change provider output → callback output in flow
  2. Call the API
  3. Inspect the returned HTML
  4. Verify variables are replaced correctly
  5. Switch back to provider output when fixed
{
  "success": true,
  "type": "callback",
  "html": "<!DOCTYPE html>...",
  "text": "Plain text...",
  "subject": "Your subject"
}

Render-Only Debugging

Use /render to test template rendering without sending:

curl -X POST https://api.mailsh.it/v1/render \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": "tmpl_abc123",
    "variables": {
      "firstName": "Test"
    }
  }'

Check the HTML output for:

  • Variable replacement
  • Correct structure
  • Subject line

Common Debug Scenarios

Email Not Arriving

  1. Check API response - Did it say success?
  2. Check spam folder - Common for new senders
  3. Check provider dashboard - Delivery status
  4. Verify recipient - Correct email address?
  5. Check provider limits - Quota exceeded?

Wrong Content in Email

  1. Check template - Correct template ID?
  2. Check variables - All provided correctly?
  3. Test with /render - See raw output
  4. Check for typos - Variable names are case-sensitive

Verification Failing

  1. Read the error - Which field failed?
  2. Check the value - Is it valid?
  3. Test verification - Use /verify endpoint
  4. Check flow config - Verification settings correct?

Logging Recommendations

Log these for debugging:

// Before sending
console.log('Sending email:', {
  templateId,
  to: recipient,
  variables: Object.keys(variables),
})

// After response
console.log('Email result:', {
  success: result.success,
  type: result.type,
  messageId: result.messageId,
  error: result.error,
})

Don’t log:

  • Full email content (privacy)
  • API keys
  • Sensitive variable values

Provider-Side Debugging

Resend

  • Activity feed shows all sends
  • View email content
  • See delivery status

SendGrid

  • Activity tab for email status
  • Event webhooks for real-time updates
  • Suppression lists for bounces

Postmark

  • Activity stream
  • Message details
  • Bounce tracking

AWS SES

  • CloudWatch metrics
  • SNS notifications for bounces
  • Sending statistics

Testing in Development

Local Testing

Use callback output to test without sending:

// In development, always use callback
const endpoint = isDev
  ? '/v1/render'
  : '/v1/execute'

Test Recipients

Send test emails to:

  • Your own email
  • Email testing services (Mailinator, etc.)
  • Team distribution list

Test Variables

Create a test payload with all variables:

const testVariables = {
  firstName: 'Test',
  lastName: 'User',
  orderNumber: 'TEST-12345',
  // ... all variables
}

Checklist

When debugging, check:

  • API key is valid
  • Template ID is correct
  • Template is in flow graph
  • Variables match template
  • _to is valid email
  • Provider is configured
  • Provider credentials are valid
  • Sender domain is verified
  • Not hitting rate limits

Getting Help

If you’re stuck:

  1. Gather information:

    • API request (without secrets)
    • API response
    • Template ID
    • Error message
  2. Check documentation for the specific error

  3. Contact support with the gathered information