django-mailgun
django-mailgun copied to clipboard
MailgunAPIError: <Response [400]>
Hi,
I just following your readme, but I keep getting this error :
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,
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
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.
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.
Hi,
I still cannot get this work... So I have to convert to gmail, unfortunately :(
Is there any solution for this?
Thank you
You can see error details in your Mailgun Logs. I got 400 response because I haven't activated account.
This project is unsupported. Please use https://github.com/anymail/django-anymail instead.
Got the same error
@alzearafat try below settings in mailgun
Security Settings For Outgoing Mail Certificate Verification Not Required
it works for me
@ithinco
Hi,
Thank you, I will test it out!
Thanks ! :D
I had the same problem. Changing Certificate verification to: Not Required fixed this, see image from Mailgun settings: