Giter Site home page Giter Site logo

django-mailgun's People

Contributors

alex avatar bradwhittington avatar bryanhelmig avatar danifus avatar frankwiles avatar ghinch avatar jseutter avatar karabijavad avatar matkot avatar omidraha avatar pydanny avatar ryneeverett avatar sonthonaxrk avatar vstoykov avatar wli avatar wmsmith avatar zakdoek avatar zdavisk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-mailgun's Issues

Less reliance on python stdlib to encode email.

Not dissimilar to #9, we are going to try using Mailgun's email encoding:

#....
clean_all = lambda addrs: [sanitize_address(addr, email_message.encoding) for addr in addrs]

from_email = sanitize_address(email_message.from_email, email_message.encoding)
text = None
html = None

if email_message.content_subtype == 'plain':
    text = email_message.body

if email_message.content_subtype == 'html':
    html = email_message.body

if isinstance(email_message, EmailMultiAlternatives):
    for body, mime in email_message.alternatives:
        if mime == 'text/html':
            html = body

try:
    r = requests.post(
        url=self._api_url + 'messages',
        auth=('api', self._access_key),
        data={
            'from': from_email,
            'to': clean_all(email_message.to),
            'cc': clean_all(email_message.cc),
            'bcc': clean_all(email_message.bcc),
            'subject': email_message.subject,
            'text': text,
            'html': html,
        },
        files=[
            ('attachment', (filename, content))
            for filename, content, mimetype in [
                attachment for attachment in email_message.attachments
                if isinstance(attachment, tuple)
            ]
        ]
    )
#....

Happy to get a PR going if you think that might be useful. It isn't complete yet.

New Feature: support scheduled delivery

Mailgun has a feature to schedule delivery of messages at a given date and time. All is needed is to pass an extra parameter to the Mailgun API call with the date.

That would be a nice to have, but could become quite a chunk as it would possibly need:

  • New send_scheduled_mail wrapper
  • Using a new ScheduledEmailMessage with delivery_date attribute (don't think monkey-patching a non-standard attribute on Django's EmailMessage is a clean solution)
  • Update MailgunBackend._send to add this attribute to the API call with the correct format only if it's present in the email_message

Happy to implement it if agreed.

pip install problem in python 3

I used pip install django-mailgun to add the app to my Django project.
It seems the code in pip is not synced with github.

try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO

Tests failing for Python 3

I wanted to do a new release. Alas, Python 3 is broken - I should have run tests on all versions of Python before accepting pull requests . For that matter, I should have set up continuous integration. This needs to be fixed before I'll issue a release.

Problem: I simply don't have the free time to support a library for a commercial endeavor (@mailgun).

If someone can get the tests working properly for Python 2.7 and Python 3.5 I'll issue a release.In the meantime, the project is on hold.

Sending html only message convert it to text

When i want to send an html only message without a text part, django mailgun send the whole message as text, not as html.
I fixed it in my fork, let me know if u think its a valid issue then i`l create a pull request.

Error in EmailMessage with MIMEBase attachment

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.

MailgunAPIError: <Response [400]>

Hi,

I just following your readme, but I keep getting this error :

Image of Yaktocat

This is my setting (I'm not sure, whether I should using secret key or public key, but both is error when I'm trying to send email) :

EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
MAILGUN_ACCESS_KEY = 'key-06b1d48a5805393c825ceefa054bXXXX'
MAILGUN_SERVER_NAME = 'sandboxfa1f6fe021044f319c639f9da08eXXXX.mailgun.org'

My views.py :

def order_form(request):
    if request.method == "POST":
        form = OrderForm(request.POST, request.FILES)
        if form.is_valid():
            order = form.save(commit=False)
            order.tanggal_order = datetime.datetime.now()
            order.save()
            subject = "NEW ZEGUYO ORDER"
            to = [order.email, '[email protected]', '[email protected]']
            from_email = '[email protected]'
            ctx = {
                'nama': order.nama,
                'id_order': order.id,
            }
            message = get_template('email/order_email.html').render(Context(ctx))
            msg = EmailMessage(subject, message, to=to, from_email=from_email)
            msg.content_subtype = 'html'
            msg.send()
            return render(request, 'order_app/order_success.html')
    else:
        form = OrderForm()
    return render(request, 'order_app/order_form.html', {'form': form})

I'm using django 1.9.2, Python 2.7

Did I miss something here?

Thank you in advance for any help you can provide :)

Regards,

Update PyPi version of django-mailgun

I see that the master branch of django-mailgun has support for python3 because it uses the io module instead of the StringIO module, but this change is not reflected in the newest version of django mailgun on PyPi.

Wheel file on pypi is broken

The wheel package of the latest version on pypi (https://pypi.python.org/packages/2.7/d/django-mailgun/django_mailgun-0.7.0-py2.py3-none-any.whl#md5=f9f840324bee50550cfe4278ad29b5e1) has an init.py that contains an older version of django-mailgun. When our app tries to send emails, Django uses this version of the backend which has none of the latest changes, and not the updated version of the code in django_mailgun.py. Removing the init file solves the issue, as then Django uses django_mailgun.py.

Using Django 1.8.4, django-mailgun 0.7.0

No v2.2 tag

I see on Pip that django-mailgun is up to 2.2, but your github tags only go up to 2.1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.