在Django中发送大量电子邮件 -- Too many values to unpack

4
我正在尝试使用Django的mass_mail功能。下面的代码会一直引发“Too Many Values to Unpack”错误,我搞不清楚为什么。我按照文档(https://docs.djangoproject.com/en/1.5/topics/email/#send-mass-mail)进行操作,看起来很简单 - 我做错了什么?如果有影响的话,发送电子邮件的地址是虚构的,但我认为这并不重要。
if matching_record.level == 1:
                users = self._get_users_to_be_notified(matching_record.category)
                email_recipients = [str(user.email) for user in users if user.email]
                message = 'Here is your requested notification that the service "%s" is having technical difficulties and has been set to "Critical".' %matching_record.name
                mail_tuple = ('Notification', 
                              message, 
                              'notifications@service.com', 
                              email_recipients)
                send_mass_mail(mail_tuple)
1个回答

6

send_mass_mail 方法的第一个参数是一个消息元组的元组,但你只发送了一个消息元组。请像下面这样更改函数调用并检查它是否正常工作:

send_mass_mail((mail_tuple,))

哦,太简单了!谢谢! - thumbtackthief

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接