How to Easily Resend Failed Emails in Postmark

If you’ve got some failed emails in Postmark, don’t worry — resending them is easy. Whether it's inbound or outbound emails, follow these simple steps to get them back on track.

Step 1: Get Your API Token

First, grab your Postmark API token:

  1. Log in to your Postmark account.

  2. Navigate to your server.

  3. Go to the API Tokens section and copy your token.

Step 2: Prepare Your cURL Command

Use this script to resend your failed emails. Replace <YOUR_API_TOKEN> with your actual token and update the message IDs:

API_TOKEN="<YOUR_API_TOKEN>"

INBOUND_MESSAGE_IDS=(
    "a0c0-4262-53298da3-1626b52bbdad"
    "9281-4c9c-19968944-fc762efa0780"
    "1977-4545-44e34e2f-eaf3c77a042d"
)

OUTBOUND_MESSAGE_IDS=(
    "0e98-4b3c-84e103f2-e816a17b908b"
    "c7f3-409f-15dc175f-2aa477e41053"
    "8fa3-4e7f-3c8dc320-cb49f17a8db7"
    "9aca-404e-8414b0d6-4879b92e4c0d"
)

# Retry inbound messages
for MESSAGE_ID in "${INBOUND_MESSAGE_IDS[@]}"; do
  curl -X PUT "https://api.postmarkapp.com/messages/inbound/${MESSAGE_ID}/retry" \
       -H "Accept: application/json" \
       -H "Content-Type: application/json" \
       -H "X-Postmark-Server-Token: ${API_TOKEN}" \
       -d ""
done

# Retry outbound messages
for MESSAGE_ID in "${OUTBOUND_MESSAGE_IDS[@]}"; do
  curl -X PUT "https://api.postmarkapp.com/messages/outbound/${MESSAGE_ID}/retry" \
       -H "Accept: application/json" \
       -H "Content-Type: application/json" \
       -H "X-Postmark-Server-Token: ${API_TOKEN}" \
       -d ""
done

Step 3: Run the Script

Save the script to a file, for example resend_postmark_emails.sh, and run it with:

sh resend_postmark_emails.sh

Alternatively, run each curl command individually in your terminal.

And That’s It!

By following these steps, you can easily retry failed inbound and outbound emails in Postmark.

Happy emailing!