因此,我尝试了所有可能的组合,无法将reply_to
对象传递给标题;即使我硬编码reply_to电子邮件地址。除了没有任何问题之外,表单的工作方式不同谢谢你的帮助
版本
Django==1.10.1
sendgrid==3.6.3
sendgrid-django==4.0.4
查看
def index(request):
form_class = FooterForm
if request.method == 'POST':
form = form_class(data=request.POST)
if form.is_valid():
fullname = request.POST.get('fullname')
phone_number = request.POST.get('phone_number')
email_address = request.POST.get('email_address')
message_content = request.POST.get('message_content')
subject = 'Contact Information Submitted from Trust and Beneficiary Advocates'
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = 'info@trustadvocates.com'
bcc = 'charles@studiorooster.com'
ctx = {
'title': 'Trust and Beneficiary Advocates',
'subject': subject,
'fullname': fullname,
'phone_number': phone_number,
'email_address': email_address,
'message_content': message_content
}
message = get_template('email_forms/contact_form_email.html').render(Context(ctx))
msg = EmailMessage(
subject,
message,
from_email,
[recipient_list],
[bcc],
reply_to=['helpme@helpme.com']
)
msg.content_subtype = 'html'
msg.send()
return redirect('/thank-you/')
return render(request, 'pages/index.html', {
'form': form_class, 'title': 'Trust and Beneficiary Advocates'
})
回复尝试组合
reply_to=['helpme@helpme.com']
headers={'Reply-To': 'helpme@helpme.com'}
答案 0 :(得分:1)
您的代码看起来不错 - 使用reply_to=['helpme@helpme.com']
应该可以在Django 1.8+中使用。
看起来你已经在sendgrid-django中点击了this bug。您可以尝试在pull request 51中应用此修复程序(它只支持单个回复地址,但在您的情况下看起来没问题),或者您可以切换到另一个服务来发送电子邮件。