Django 6.1 will allow configuring multiple email backends via a new MAILERS dict setting with separate OPTIONS for each configuration. It also deprecates the current EMAIL_BACKEND setting.
Anymail's backends already allow configuration by keyword arguments, so already support MAILERS and OPTIONS. These settings should work just fine with the current django-anymail 15.0 (or earlier) and Django 6.1:
MAILERS = {
"default": {
"BACKEND": "anymail.backends.amazon_ses.EmailBackend",
"OPTIONS": {
"client_params": {"region_name": "us-west-2"},
"configuration_set_name": "django-transactional",
},
},
"marketing": {
"BACKEND": "anymail.backends.postmark.EmailBackend",
"OPTIONS": {
"server_token": "...",
"send_defaults": {
"esp_extra": {"MessageStream": "broadcast"},
},
},
},
"sandbox": {
"BACKEND": "anymail.backends.mailtrap.EmailBackend",
"OPTIONS": {
"api_token": "...",
"sandbox_id": 12345,
},
},
}
# And no need to define ANYMAIL settings for sending.
# (You might still need ANYMAIL for, e.g., webhook validation keys.)
But we need to:
Django 6.1 will allow configuring multiple email backends via a new
MAILERSdict setting with separate OPTIONS for each configuration. It also deprecates the currentEMAIL_BACKENDsetting.Anymail's backends already allow configuration by keyword arguments, so already support
MAILERSand OPTIONS. These settings should work just fine with the current django-anymail 15.0 (or earlier) and Django 6.1:But we need to:
MAILERS(and explain thatMAILERSOPTIONS take precedence over the correspondingANYMAILsettings when both are defined)EMAIL_BACKENDon Django 6.1 or lateresp_extra, to simplify configuration (e.g., Postmark'sMessageStreamlike shown above)