We're experiencing difficulty. Our engineers are on it. Please check status.mailgun.com for real-time updates.

Resending messages

Article Preview

    Overview

    Do you need to resend a particular message that has been previously submitted to Mailgun? Perhaps the message failed when delivery to the recipient was first attempted due to a problem with the recipient's mailbox. Or, perhaps for some reason a recipient does not see the message in their mailbox and has requested for you to resend it.

    Message resending is possible by using either the Messages API or the Logs page of the Mailgun Control Panel. However, the key prerequisite is that the message must still exist within the Mailgun's environment.

     

    Determining whether the message exists

    Whether you can use Mailgun to resend any particular message depends on three factors that govern how long any particular message persists within Mailgun (and thus, whether the message is available to view or resend):

    • the account's plan at the time the message was submitted to Mailgun (primary factor)
    • the sending domain's retention settings at the time the message was submitted to Mailgun (secondary factor)
    • the elapsed time since the message was submitted to Mailgun (variable factor)

    If the message has expired due to any or all of the above reasons, you must construct and submit a new message to Mailgun.

     

    Account's plan

    Your account's plan is the main factor that determines how long messages are retained on your account. 

    To view the account's plan(s):

    1. In the top-right corner of the Mailgun Control Panel, click your Profile Menu to expand the drop-down list of options.
    ContentBlock-ProfileMenu.png
    1. Next, click the Plan & Billing option. Alternatively, you can use this direct link
    ContentBlock-ProfileMenu-Plans&Billing.png
    1. The resulting page displays the Plans tabbed section, which lists the account's current plan(s). The bullet point for "message retention" states how many days a message can* exist on your account.

      Note: regarding plans that provide greater than 3 days of message retention, the retention period must be increased on a domain-by-domain basis since a domain's default retention period is 3 days.
    Screenshot 2023-09-11 at 9.12.45 AM.png

    Alternatively, you may view a plan's message retention on the Mailgun pricing page.

    Which method do we recommend? The Control Panel method as it will always be reflective of and personalized to your account.

     

    Sending domain's retention settings

    Mailgun allows storage of message bodies for later retrieval (either rendered via the Control Panel or retrieved via API). The maximum number of days of available retention is set by your account's plan.

    Note: increases in the retention setting are not retroactive, which means that adjusting the domain's retention period from 3 days to 7 days does not allow you to resend a message that is already 4-7 days old at the time the setting was changed. Such messages will have already expired from Mailgun's infrastructure. 

    To view a domain's message retention settings:

    1. Within the Navigation Menu on the left side of the Mailgun Control Panel, click the Domain settings sub-option. (If needed, click the Sending option first to expand the drop-down list of sub-options). 
    ContentBlock-Sidenav-DomainSettings.png
    1. Near the top-right corner of the Mailgun Control Panel, ensure that the intended domain is selected within the Domain drop-down list before proceeding to the next step.
    ContentBlock-DomainSelector.png
    1. The resulting page displays the Domain settings tabbed section, which shows the domain's current message retention period (among various other settings). 

      Note: regarding plans that provide greater than 3 days of message retention, the retention period must be increased on a domain-by-domain basis since a domain's default retention period is 3 days.
    ContentBlock-DomainSettings-MessageRetention.png

     

    Elapsed time

    In light of the account's plan and sending domain's message retention settings, how long ago the original message was submitted to Mailgun is the final determining factor as to whether the message still exists within Mailgun.

    Let's illustrate with a few examples:

    • Example 1: An account subscribes to the Foundation plan, which provides up to 1 day of message retention. Attempting to retry a message sent 2 days ago will not be possible since the message has already expired.
    • Example 2: An account subscribes to the Scale plan, which provides up to 7 days of message retention. However, the sending domain in question is configured for 3 days of message retention by default. Attempting to retry a message sent 4 days ago will not be possible since the message has already expired.
    • Example 3: An account subscribes to the Scale plan, which provides up to 7 days of message retention. Accordingly, the sending domain in question is configured for 7 days of message retention. Attempting to retry a message sent 4 days ago will be possible since the message has not yet expired.

    We will discuss in the Resending the message - Method 2: Messages API section how to determine when a message was sent.

     

    Resending the message

     

    Method 1: Control Panel

    As the less technically-challenging method, ease-of-use is maximized at the expense of the automation and scalability offered by the Messages API method.

    To resend a message by using the Mailgun Control Panel (as long as the message has not expired due to exceeding either your account's or domain's message retention period):

    1. Within the Navigation Menu on the left side of the Mailgun Control Panel, click the Logs sub-option. (If needed, click the Sending option first to expand the drop-down list of sub-options). 
    ContentBlock-Sidenav-Logs.png
    1. Near the top-right corner of the Mailgun Control Panel, ensure that the intended domain is selected within the Domain drop-down list before proceeding to the next step.
    ContentBlock-DomainSelector.png
    1. Locate in the logs the message that you wish to resend. Use the filters, sorts, and searches as needed.
    ContentBlock-Logs-View.png
    1. Once a log for the intended message is located, click the gear icon ContentBlock-GearIcon.png in the Actions column to expand the drop-down list of options. Click the Resend message option.

      Note: if you do not see the Resend message option listed, then the message is expired due to exceeding either the account's or domain's message retention period, and thus, is not able to be resent.
    ContentBlock-Logs-Options.png
    1. Enter the email address of the recipient to whom you wish to resend the message. Finally, click the Resend Message button. 
    ContentBlock-Logs-ResendOption.png

     

    Method 2: Messages API

    As the more technically-challenging method, automation and scalability are maximized at the expense of the ease-of-use offered by the Control Panel method.

    To resend a message by using the Messages API** (as long as the message has not expired due to exceeding either your account's or domain's message retention period):

    1. Within the Navigation Menu on the left side of the Mailgun Control Panel, click the Logs sub-option. (If needed, click the Sending option first to expand the drop-down list of sub-options). 
    ContentBlock-Sidenav-Logs.png
    1. Near the top-right corner of the Mailgun Control Panel, ensure that the intended domain is selected within the Domain drop-down list before proceeding to the next step.
    ContentBlock-DomainSelector.png
    1. Locate in the logs the message that you wish to resend. Use the filters, sorts, and searches as needed.

      Note: the Timestamp column on the Logs page displays. Accepted, Delivered, and Failed events contain the storage properties. As such, you could filter by event=failed to narrow the logs results. Depending on the nature of your messages, you could also filter by subject or tag to narrow the log results. messages are the ones you want to resend. Filter by event=failed to narrow the logs results.
    ContentBlock-Logs-View.png
    1. Once a log for the intended message is located, click the down-arrow icon Screenshot 2023-09-11 at 2.43.08 PM.png in the Actions column (or virtually anywhere in the row containing the log) to expand the message metadata (envelope and header information).
    ContentBlock-Logs-MetaDataOverview.png
    1. Scroll or search within your web browser (Ctrl+F on Windows or Cmd+F on Mac) to locate the storage URL property. The storage URL property is the full and exact URL that will be used in your HTTP POST request to the Messages API.

      Note: if for some reason you do not, or cannot, use the storage URL property to build the Messages API request in the next step, you can alternatively use the combination of the storage region and storage key properties.
    ContentBlock-Logs-MetaDataStorageURL.png
    1. Using the storage property information, build the Messages API request and POST it to Mailgun. Ensure that all placeholder values (e.g. YOUR_API_KEY, YOUR_DOMAIN_NAME, etc.) and email recipients are updated prior to submitting the HTTP request.

      Note: provide a form parameter “to” with a string of comma separated email addresses you want to deliver the message to.

    cURL example using Storage URL property:

    curl -s --user 'api:YOUR_API_KEY' \
    {{STORAGE.URL}} \
    -F to='bob@example.com, john@example.com'

    cURL example using Storage Region and Storage Key properties:

    curl -s --user 'api:YOUR_API_KEY' \
    https://storage-{{MESSAGE_STORAGE_REGION}}.api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/messages/STORAGE_KEY \
    -F to='bob@example.com, john@example.com'

     

    ** Technical note: the Events API can be used instead of the Control Panel to obtain the storage URL. However, without implementing sophisticated programming logic to select and automate the types of messages to resend, the HTTP requests to the Events API would need to be manually performed when needed. The HTTP JSON response received from the Events API will need to be parsed for the relevant data (which is also available in the Logs of the Control Panel). Once that data is obtained, it then can be used in the creation of the HTTP POST to the Messages API to perform the message retry.

    Need Support?

    Our Support Team here at Sinch Mailgun is happy to help! Reach out to us in the Support section of your Mailgun Control Panel, and we'll be with you shortly!