简体   繁体   English

Django-Anymail在Digital Ocean上的docker中出现“Mailgun Magnificent API”错误

[英]“Mailgun Magnificent API” error with Django-Anymail in docker on Digital Ocean

I am running a django application running on docker and I am using django-anymail to send emails via mailgun. 我正在运行在docker上运行的django应用程序,我正在使用django-anymail通过mailgun发送电子邮件。

When I go through for example a forgot my password process I am getting an error in django-anymail: 当我通过例如忘记我的密码过程时,我在django-anymail中收到错误:

AnymailRequestsAPIError: Invalid JSON in Mailgun API response Sending a message to testemail@test.com from info@ application .co.uk Mailgun API response 200 (OK): 'Mailgun Magnificent API' @ anymail/backends/base_requests.py in deserialize_json_response at line 106 AnymailRequestsAPIError:Mailgun API响应中的无效JSON从info @ application .co.uk向testemail@test.com发送消息Mailgun API响应200(OK):'mailgun Magnificent API'@allmail / backends / base_requests.py inserialize_json_response at line 106

I am able to re-create this error if I docker exec -it onto the django container and run the following in a python manage.py shell 如果我将docker exec -it放到django容器上并在python manage.py shell运行以下命令,我可以重新创建此错误

from django.core.mail import send_mail 
customer_email = send_mail('Test','Test','info@*application*.co.uk',["*test@test.com*"],fail_silently=False) 

If I run this after building and running my production.yml docker locally it works and I get an email but if I run this on the container on my digital ocean droplet I receive an error. 如果我在本地构建并运行我的production.yml docker后运行它,它可以工作,我收到一封电子邮件,但如果我在我的数字海洋液滴上的容器上运行它,我收到一个错误。

Is there a configuration I am missing in order to get this working? 是否有一个我缺少的配置才能使这个工作? I have another django application just running on a droplet(no docker) and it works fine with mailgun using the same setup. 我有另一个django应用程序只是在一个droplet(没有docker)上运行,它使用相同的设置与mailgun工作正常。

The error "Mailgun Magnificent API" is most likely caused by a # character in your MAILGUN_SENDER_DOMAIN. “Mailgun Magnificent API”错误很可能是由MAILGUN_SENDER_DOMAIN中的#字符引起的。 That often happens when you try to use line-end comments in a config file format that doesn't support them—like dotenv: 当您尝试以不支持它们的配置文件格式使用行结束注释时(例如dotenv),通常会发生这种情况:

# .env
MAILGUN_SENDER_DOMAIN=mail.example.com  # INVALID: dotenv doesn't allow comment here

If you upgrade to django-anymail v6.0 , you'll get an improved error message that makes this more obvious. 如果你升级到django-anymail v6.0 ,你会得到一个改进的错误信息,这使得这更加明显。

( This answer covers other situations that can lead to " Mailgun Magnificent API .") 这个答案涵盖了可能导致“ Mailgun Magnificent API ”的其他情况。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM