How to set custom sender display name in Mailgun API emails

I’m working with Mailgun API to send automated emails from my Python application and running into an issue with the sender display name. The emails are being delivered successfully, but recipients see the wrong sender information in their email clients.

When I send emails through Mailgun using [email protected] as the sender address, users see “info” as the sender name in their inbox. But I want them to see a proper display name like “Sarah from MyWebsite” instead of just the username part of the email address.

Interestingly, when I manually send emails from the same [email protected] address using a regular email client, the correct display name appears just fine. This makes me think there’s a configuration setting I’m missing in my Mailgun implementation.

Does anyone know how to properly configure the sender display name when using Mailgun’s API? I need the emails to show a friendly name rather than just the email prefix.

Change your from parameter in the Mailgun API to include both the display name and email. Instead of just [email protected], use Sarah from MyWebsite <[email protected]> (no quotes around the whole thing). The angle brackets are key - they tell Mailgun where the actual email starts and stops. I ran into this exact issue. Most email clients just show the username part when you don’t set a display name through the API. Update the from field in your Python requests payload, not the reply-to or other headers.

Had the same issue recently. Some email clients are way pickier about formatting than others. Here’s what fixed it for me: strip out any special characters or punctuation from the display name - they can break the parsing. Also, double-check that your domain’s actually verified in Mailgun. I’ve seen unverified domains randomly strip display names. If it’s still not working, test with something simple like “Sarah” instead of “Sarah from MyWebsite” to see if length or specific words are the problem. RFC 2822 can be pretty strict about display name formatting.

just wrap the display name in quotes with the email address like this: “Sarah from MyWebsite” [email protected] when you’re setting the from field in your API call. that’s how I got mine working - mailgun parses it correctly and shows the proper sender name.