Django 和 Mailgun:552 抱歉,您的信封发件人域必须存在 (#5.7.1)

Django and Mailgun : 552 sorry, your envelope sender domain must exist (#5.7.1)

我正在尝试通过 Anymail 包和 OVH 服务器使用 Django 和 Mailgun 发送邮件。

我目前收到 552 sorry, your envelope sender domain must exist (#5.7.1) 错误。

this question/answer 中,建议我需要一个 "from" header,但我得到的响应似乎表明 header 已经包括:

    "headers": {
      "to": "evenements@mydomain-longversion.org",
      "message-id": "20160915065953.15168.46300.4ABD80EB@mailgun.mydomain.fr",
      "from": "covoiturage@mydomain.fr",
      "subject": "Mail test !"
    },

完整回复,供参考:

{
  "severity": "permanent",
  "tags": [],
  "storage": {
    "url": "https://si.api.mailgun.net/v3/domains/mailgun.mydomain.fr/messages/eyJwIjpmYWxzZSwiayI6ImI5OGIyN2QzLTM2MmEtNGJjNi05ZWViLTRlMTA0NTVmYTIxMiIsInMiOiJlNmY5NzZhZTYwIiwiYyI6InNiaWFkIn0=",
    "key": "eyJwIjpmYWxzZSwiayI6ImI5OGIyN2QzLTM2MmEtNGJjNi05ZWViLTRlMTA0NTVmYTIxMiIsInMiOiJlNmY5NzZhZTYwIiwiYyI6InNiaWFkIn0="
  },
  "delivery-status": {
    "tls": false,
    "mx-host": "redirect.ovh.net",
    "attempt-no": 1,
    "description": null,
    "session-seconds": 0.9216420650482178,
    "code": 552,
    "message": "552 sorry, your envelope sender domain must exist (#5.7.1)",
    "certificate-verified": false
  },
  "recipient-domain": "mydomain-longversion.org",
  "event": "failed",
  "campaigns": [],
  "reason": "generic",
  "user-variables": {},
  "flags": {
    "is-routed": null,
    "is-authenticated": true,
    "is-system-test": false,
    "is-test-mode": false
  },
  "log-level": "error",
  "timestamp": 1473922798.282194,
  "envelope": {
    "transport": "smtp",
    "sender": "postmaster@mailgun.mydomain.fr",
    "sending-ip": "209.61.151.224",
    "targets": "evenements@mydomain-longversion.org"
  },
  "message": {
    "headers": {
      "to": "evenements@mydomain-longversion.org",
      "message-id": "20160915065953.15168.46300.4ABD80EB@mailgun.mydomain.fr",
      "from": "covoiturage@mydomain.fr",
      "subject": "Mail test !"
    },
    "attachments": [],
    "recipients": [
      "evenements@mydomain-longversion.org"
    ],
    "size": 643
  },
  "recipient": "evenements@mydomain-longversion.org",
  "id": "TfJKwpoZQq6bM-MW5sm6nA"
}

这是我的 Django 代码:

def SendTestEmail(request):
    if request.user.is_staff and settings.DEBUG == True :
        send_mail(
            subject='Mail test !',
            message='''Bonjour {}, votre email a bien été envoyé.'''.format(request.user.get_full_name()),
            recipient_list=['evenements@mydomain-longversion.org',],
            from_email=settings.DEFAULT_FROM_EMAIL,
            fail_silently=False,
        )
        messages.success(request, 'Email correctement envoyé !')
    return redirect('rideshare_event_list')

尝试使用 covoiturage@mailgun.mydomain.fr 作为您的发件人地址,而不是 covoiturage@mydomain.fr

恐怕我不确定是否可以使用 covoiturage@mydomain.fr 作为发件人地址。