当我以这种方式调用send_templated_mail()时:
from templated_email import send_templated_mail
send_templated_mail(
template_name='welcome',
from_email='from@email.com',
recipient_list=['recipient@email.com'],
context={
'username':'username1',
'full_name':'user name',
'signup_date':'today',
},
headers={'My-Custom-Header':'Custom Value'}
)
我收到以下TypeError:
send_templated_mail()至少需要4个参数(给定1个)
根据我的阅读,只有3个必需的参数,它们是列出的前三个。知道造成TypeError的原因是什么?提前谢谢。
以下是连接到MailChimp的相关settings.py设置:
TEMPLATED_EMAIL_BACKEND = 'templated_email.backends.mailchimp_sts.TemplateBackend'
MAILCHIMP_API_KEY = 'myAPIkey'
#For the django back-end specifically
TEMPLATED_EMAIL_MAILCHIMP = {
'welcome':{
'subject':'Welcome to my website',
'track_opens':True,
'track_clicks':False,
'tags':['my','little','pony'],
}
}
#Email template repository
TEMPLATED_EMAIL_TEMPLATE_DIR = 'templated_email/'
TEMPLATED_EMAIL_FILE_EXTENSION = 'email'
答案 0 :(得分:0)
您也可以尝试此设置
from templated_email import send_templated_mail
send_templated_mail(
'email',
'from@yourwebsite.com',
['to@person.com'],
{ 'username':username1 }
)
在settings.py
添加
TEMPLATED_EMAIL_DJANGO_SUBJECTS = {'email':'welcome',}
使用该行代码,它将自动查找名为“templated_email / email.txt”或“templated_email / email.html”的任何模板