Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Error in EmailMessage with MIMEBase attachment #36

Open
yuvadm opened this issue Mar 24, 2016 · 2 comments
Open

Error in EmailMessage with MIMEBase attachment #36

yuvadm opened this issue Mar 24, 2016 · 2 comments

Comments

@yuvadm
Copy link

yuvadm commented Mar 24, 2016

An email message with alternative is built like so:

email_message = EmailMultiAlternatives(subject, body, from_email, [to_email])
email_message.attach_alternative(foo, 'text/html')
email_message.mixed_subtype = 'related'
email_message.attach(MIMEImage(image_fp.read()))
email_message.content_subtype = "html"
email_message.send()

When sent via mailgun the following error is given:

AttributeError("'int' object has no attribute 'lower'",)
Traceback (most recent call last):
  File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/core/mail/message.py
", line 303, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/opt/python/run/venv/local/lib/python2.7/site-packages/django_mailgun.py", line 16
8, in send_messages
    if self._send(message):
  File "/opt/python/run/venv/local/lib/python2.7/site-packages/django_mailgun.py", line 13
7, in _send
    post_data.append(('attachment', (attachment[0], attachment[1],)))
  File "/usr/lib64/python2.7/email/message.py", line 294, in __getitem__
    return self.get(name)
  File "/usr/lib64/python2.7/email/message.py", line 360, in get
    name = name.lower()
AttributeError: 'int' object has no attribute 'lower'

The Django attach() API accepts both MIMEBase parameters as well as (filename, content, mimetype) triplets and it seems django-mailgun doesn't support the former.

@x007007007
Copy link

hi, #37 may be helpful.

@pydanny
Copy link
Collaborator

pydanny commented May 4, 2016

This project is unsupported. Please use https://github.com/anymail/django-anymail instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants