Mailgun emails not sent, with error message "Forbidden"

Problem statement

We use Mailgun as the external SMTP provider. Emails are suddenly not being delivered.

Tenant logs with log type “fn” does not have error details.

 "details": {
    "email_type": "welcome_email",
    "to": REDACTED EMAIL,
    "error": ""
  },

Troubleshooting

Tenant logs search for api/v2 updates to the email provider:

type:"sapi" AND (description:"Update an email template" OR description:"Patch an email template" OR description:"Update the email provider")

Results showed a recent Update Email Provider log entry made with the Deploy CLI:

  "method": "patch",
  "path": "/api/v2/emails/provider",
  "query": {
    "enabled": "true",
    "name": "mailgun"
  },
  "userAgent": "deploy-cli/7.15.2 (node.js/14.17.3)",
  "body": {
    "name": "mailgun",
    "default_from_address": REDACTED,
    "enabled": true
  },

Cause

The Deploy CLI update removed the API Key previously configured for the SMTP provider. This can happen if the keyword mappings for the Deploy CLI are misconfigured. Deploy CLI Tool Environment Variables and Keyword Mappings

Solution

Make sure that the correct Mailgun API Key is used on the Email Provider page of the Dashboard.