JSON-LD structured data not functioning when using Mailgun SMTP

I’m having trouble with structured data markup when sending emails through Mailgun’s SMTP service. I’ve created an HTML email template that includes JSON-LD schema markup for booking confirmations. The weird thing is that when I send the exact same email using Google Apps Script, the structured data works perfectly and shows up correctly. But when I use Mailgun SMTP to send it, the markup doesn’t get processed at all.

Has anyone experienced this issue before? I’m wondering if Mailgun strips out certain elements or if there’s something specific about how they handle HTML emails that breaks the structured data.

Here’s my email template with the schema markup:

<!DOCTYPE html>
<html>
<head>
    <title>Booking Confirmation</title>
    <meta charset="UTF-8">
    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "EventReservation",
      "confirmationNumber": "abc123-def456-ghi789",
      "reservationStatus": "http://schema.org/Confirmed",
      "underName": {
        "@type": "Person",
        "name": "John Smith"
      },
      "reservationFor": {
        "@type": "Event",
        "name": "Restaurant Booking",
        "startDate": "2024-01-15T19:00:00",
        "location": {
          "@type": "Place",
          "name": "Downtown Bistro",
          "address": {
            "@type": "PostalAddress",
            "streetAddress": "123 Main Street, New York, NY 10001"
          },
          "geo": {
            "@type": "GeoCoordinates",
            "latitude": "40.7128",
            "longitude": "-74.0060"
          }
        },
        "performer": "Dinner Reservation"
      },
      "modifyReservationUrl": "https://example.com/modify?token=abc123-def456-ghi789"
    }
    </script>
</head>
<body>
    Your reservation has been confirmed.
</body>
</html>

This usually happens because email clients process messages differently, not because of Mailgun itself. Google Apps Script uses Google’s own infrastructure, so Gmail automatically trusts it for structured data. Third-party SMTP services get hit with stricter validation.

Here’s what worked for me: Make sure you’re explicitly setting the email MIME type to text/html in your Mailgun API call. Also check if you’re using Mailgun’s template engine or sending raw HTML - their template engine sometimes messes with the content structure.

I’d test with a simple booking confirmation first, then add complexity bit by bit to figure out what’s breaking the markup. The authentication setup others mentioned is definitely important, but I’ve also seen cases where Content-Type headers weren’t set properly through the SMTP connection. Gmail ends up treating the email as plain text even though it’s formatted as HTML.

mailgun can mess with html headers during delivery, which breaks structured data parsing. try moving your json-ld script tag from the head to the body section - fixed the same issue for me when booking confirmations weren’t showing up in gmail.

Had the same issue 6 months back with a different email provider. It’s not that Mailgun strips JSON-LD - it’s how email clients handle structured data based on your sender reputation and authentication setup. Gmail’s approach is pickier about processing structured data from third-party SMTP compared to their own servers. Ensure that your SPF, DKIM, and DMARC records are correctly configured with Mailgun. Additionally, check whether you’re using a dedicated or shared IP, as shared IPs typically have lower trust scores that can affect structured data processing. You might also consider sending from a Gmail account through Mailgun’s SMTP to determine if it’s an authentication problem rather than an issue with the service.