7d7448011b961b742ab053f29e265a554eff8297
 anymail/utils.py              |  6 ++++++
 tests/test_mailgun_backend.py | 26 ++++++++++++++++++++++++--
 tests/utils.py                |  3 +++
 3 files changed, 33 insertions(+), 2 deletions(-)
Note: Test changes not included for simplicity (not run during package build
anyway).
diff --git a/anymail/utils.py b/anymail/utils.py
index 66c307a..f9e71ad 100644
--- a/anymail/utils.py
+++ b/anymail/utils.py
@@ -171,6 +171,12 @@ class Attachment(object):
         if isinstance(attachment, MIMEBase):
             self.name = attachment.get_filename()
             self.content = attachment.get_payload(decode=True)
+            if self.content is None:
+                if hasattr(attachment, 'as_bytes'):
+                    self.content = attachment.as_bytes()
+                else:
+                    # Python 2.7 fallback
+                    self.content = attachment.as_string().encode(self.encoding)
             self.mimetype = attachment.get_content_type()
 
             if get_content_disposition(attachment) == 'inline':
