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

MailgunAPIError: <Response [400]> #34

Open
alzearafat opened this issue Feb 25, 2016 · 9 comments
Open

MailgunAPIError: <Response [400]> #34

alzearafat opened this issue Feb 25, 2016 · 9 comments

Comments

@alzearafat
Copy link

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,

@RyanSCL
Copy link

RyanSCL commented Mar 23, 2016

I've got this error too when moving from staging to production. I'm guessing it has something to do with ALLOWED HOSTS but I have not been able to crack it as yet

@pydanny
Copy link
Collaborator

pydanny commented Mar 23, 2016

Apologies for leaving this hanging for so long. Life got in the way. Does anyone know if Mailgun changed their API?

FWIW, I'm not having these problems myself. I can't reproduce them. Not yet anyway.

@RyanSCL
Copy link

RyanSCL commented Mar 23, 2016

I received the same error message, it was due a typo in an e-mail template. MailGun raised a 400 which sent me on a wild goose hunt. In the example above, if there is something awry with the ctx, it may do the same.

@alzearafat
Copy link
Author

Hi,

I still cannot get this work... So I have to convert to gmail, unfortunately :(

Is there any solution for this?

Thank you

@ozren1983
Copy link

You can see error details in your Mailgun Logs. I got 400 response because I haven't activated account.

@pydanny
Copy link
Collaborator

pydanny commented May 4, 2016

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

@ithinco
Copy link

ithinco commented May 7, 2016

Got the same error

@alzearafat try below settings in mailgun

Security Settings For Outgoing Mail
Certificate Verification Not Required

it works for me

@alzearafat
Copy link
Author

@ithinco

Hi,

Thank you, I will test it out!

Thanks ! :D

@illagrenan
Copy link

I had the same problem. Changing Certificate verification to: Not Required fixed this, see image from Mailgun settings:

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

6 participants