anymail / django-anymail

Django email backends and webhooks for Amazon SES, Brevo (Sendinblue), MailerSend, Mailgun, Mailjet, Postmark, Postal, Resend, SendGrid, SparkPost, Unisender Go and more
https://anymail.dev
BSD 3-Clause "New" or "Revised" License
1.65k stars 125 forks source link

mailgun api key #335

Closed sdarwin closed 1 year ago

sdarwin commented 1 year ago

Hi, This is a question about documentation. On https://anymail.dev/en/stable/esps/mailgun/ it says:

MAILGUN_API_KEY Required for sending. Your Mailgun “Private API key” from the Mailgun API security settings:

It links to Account API Keys.

However there exists another type of API key. If you go to settings of a specific domain in mailgun they offer "sending api keys". https://app.mailgun.com/app/sending/domains/www.example.com/sending-keys

Would it be clearer in the documentation at https://anymail.dev/en/stable/esps/mailgun/ to add:

  1. "or sending api keys https://app.mailgun.com/app/sending/domains/www.example.com/sending-keys"

or

  1. "not sending api keys https://app.mailgun.com/app/sending/domains/www.example.com/sending-keys"

and, by the way, what is the difference, and which is preferred?

medmunds commented 1 year ago

Ah, at the time those docs were written, Mailgun only offered account-level API keys. Looks like the domain-specific sending keys were introduced a few years ago. (Thanks for reporting this.)

I believe either should work. The domain-specific key would generally be preferred, because Anymail doesn't need access to other parts of Mailgun's API. The exception would be if send from multiple Mailgun domains in the same app, in which case you'd need to use the account-level API key. (Or swap sending domain keys on the fly, using something like Anymail's sending hooks.)

We should update the docs to recommend using a sending domain key.

sdarwin commented 1 year ago

Logged in as another test account, so will re-send the answer: Yes, thanks for your reply, I will try using sending domain keys.