@@ -34,8 +34,7 @@ in your settings.py.
3434
3535.. rubric :: MAILGUN_API_KEY
3636
37- Required for sending. Your Mailgun "Private API key" from the Mailgun
38- `API security settings `_:
37+ Required for sending:
3938
4039 .. code-block :: python
4140
@@ -44,6 +43,37 @@ Required for sending. Your Mailgun "Private API key" from the Mailgun
4443 " MAILGUN_API_KEY" : " <your API key>" ,
4544 }
4645
46+ The key can be either:
47+
48+ * (recommended) a domain-level Mailgun "Sending API key," found in Mailgun's dashboard
49+ under "Sending" > "Domain settings" > "Sending API keys" (make sure the correct
50+ domain is selected in the popup at top right!)
51+ * an account-level "Mailgun API key" from your Mailgun `API security settings `_.
52+
53+ The account-level API key permits sending from any verified domain,
54+ but it also allows access to all other Mailgun APIs for your account
55+ (which Anymail doesn't need).
56+
57+ The domain-level sending API key is preferred if you send from only
58+ a single domain. With multiple domains, either use an account API key,
59+ or supply the sending API key for a default domain in settings.py and
60+ use Django's :func: `~django.core.mail.get_connection ` to substitute
61+ a different sending API key for other domains:
62+
63+ .. code-block :: python
64+
65+ from django.core.mail import EmailMessage, get_connection
66+ # By default, use the settings.py MAILGUN_API_KEY:
67+ message1 = EmailMessage(from_email = " support@default-domain.example.com" , ... )
68+ message1.send()
69+
70+ # Use a different sending API key for this message:
71+ connection = get_connection(api_key = SENDING_API_KEY_FOR_OTHER_DOMAIN )
72+ message2 = EmailMessage(from_email = " support@other-domain.example.com" , ... ,
73+ connection = connection)
74+ message2.send()
75+
76+
4777 Anymail will also look for ``MAILGUN_API_KEY `` at the
4878root of the settings file if neither ``ANYMAIL["MAILGUN_API_KEY"] ``
4979nor ``ANYMAIL_MAILGUN_API_KEY `` is set.
@@ -115,7 +145,7 @@ Email sender domain
115145-------------------
116146
117147Mailgun's API requires identifying the sender domain.
118- By default, Anymail uses the domain of each messages 's `from_email `
148+ By default, Anymail uses the domain of each message 's `from_email `
119149(e.g., "example.com" for "from\@ example.com").
120150
121151You will need to override this default if you are using
0 commit comments