我正在尝试使用 Django-Templated-Email (0.4.7) 发送电子邮件,但我不断收到以下错误:
TypeError at /intake/basic/
send_templated_mail() takes at least 4 arguments (4 given)
Request Method: POST
Request URL: http://127.0.0.1:8000/intake/
Django Version: 1.5.1
Exception Type: TypeError
Exception Value:
send_templated_mail() takes at least 4 arguments (4 given)
下面是我从views.py中摘录的代码:
from templated_email import send_templated_mail
class IntakeFormView(CreateView):
"""
Creates intake form request
"""
model = Intake
form_class = IntakeForm
template_name = 'intake.html'
success_url = '/intake/sent/'
def form_valid(self, form):
# Save form to database
self.object = form.save()
from_email = 'from@fakemail.com'
recipient_list = ['get@fakemail.com']
send_templated_mail(context=
{'client': self.object.client,
'type': self.object.type,
'issue': self.object.issue},
template_name='intake',
to=['to@fakemail.com'],
bcc=recipient_list,
from_email=from_email)
return HttpResponseRedirect(self.get_success_url())
下面是intake.email 模板文件:
{% block subject %}
CLIENT ALERT: {{type}}
{% endblock %}
{% block plain %}
{{client}} needs help re {{issue}}.
{% endblock %}
谢谢您的帮助!