mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
SendGrid: update to new v3 send API (#50)
SendGrid: update to v3 send API **SendGrid:** **[possibly-breaking]** Update SendGrid backend to newer Web API v3. This should be a transparent change for most projects. Exceptions: if you use SendGrid username/password auth, esp_extra with "x-smtpapi", or multiple Reply-To addresses, please review the [porting notes](http://anymail.readthedocs.io/en/latest/esps/sendgrid/#sendgrid-v3-upgrade). Closes #28
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import mimetypes
|
||||
from base64 import b64encode
|
||||
from collections import Mapping, MutableMapping
|
||||
from datetime import datetime
|
||||
from email.mime.base import MIMEBase
|
||||
from email.utils import formatdate, getaddresses, unquote
|
||||
@@ -95,6 +96,20 @@ def getfirst(dct, keys, default=UNSET):
|
||||
return default
|
||||
|
||||
|
||||
def update_deep(dct, other):
|
||||
"""Merge (recursively) keys and values from dict other into dict dct
|
||||
|
||||
Works with dict-like objects: dct (and descendants) can be any MutableMapping,
|
||||
and other can be any Mapping
|
||||
"""
|
||||
for key, value in other.items():
|
||||
if key in dct and isinstance(dct[key], MutableMapping) and isinstance(value, Mapping):
|
||||
update_deep(dct[key], value)
|
||||
else:
|
||||
dct[key] = value
|
||||
# (like dict.update(), no return value)
|
||||
|
||||
|
||||
def parse_one_addr(address):
|
||||
# This is email.utils.parseaddr, but without silently returning
|
||||
# partial content if there are commas or parens in the string:
|
||||
|
||||
Reference in New Issue
Block a user