Mailgun电子邮件发件人并不是它应该是什么

时间:2018-02-13 10:43:59

标签: django mailgun django-email

所以我只是用mailgun设置了django电子邮件,并发送了第一封电子邮件。这是我在Django中的配置:

EMAIL_BACKEND = config('EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
EMAIL_HOST = config('EMAIL_HOST', default='')
EMAIL_PORT = config('EMAIL_PORT', default=587, cast=int)
EMAIL_HOST_USER = 'postmaster@mg.smartsurvey.xyz'
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='')
EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=True, cast=bool)

DEFAULT_FROM_EMAIL = 'SmartSurvey <noreply@smartsurvey.xyz>'

这是发送电子邮件的视图:

current_site = get_current_site(request)
subject = 'Activate your SmartSurvey account'
message = render_to_string('email/email_activation.html', {
    'name': user.get_full_name(),
    'domain': current_site.domain,
    'uid': urlsafe_base64_encode(force_bytes(user.pk)),
    'token': account_activation_token.make_token(user),
    })
user.email_user(subject, message)

我希望发件人为SmartSurvey <noreply@smartsurvey.xyz>,但目前发送方式如下:noreply=smartsurvey.xyz@mg.smartsurvey.xyz on behalf of SmartSurvey <noreply@smartsurvey.xyz>

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

只要您在“发件人:”字段中输入的域与您使用Mailgun的域不匹配,就会发生这种情况。确保这些对齐以防止&#34;代表&#34;符号