thumbtackthief
thumbtackthief

Reputation: 6211

Send mass mail in Django -- Too many values to unpack

I'm experimenting with Django's mass_mail function. The code below keeps raising a "Too Many Values to Unpack" error, and I can't figure out why. I'm following the docs (https://docs.djangoproject.com/en/1.5/topics/email/#send-mass-mail) which seem pretty straightforward--what am I doing wrong? If it matters, the send-email address is made up, but I can't see that mattering.

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, 
                              '[email protected]', 
                              email_recipients)
                send_mass_mail(mail_tuple)

Upvotes: 4

Views: 1089

Answers (1)

mshsayem
mshsayem

Reputation: 18008

send_mass_mail method's first argument is a tuple of message tuples, but you are sending just a message tuple. Change the function calling like below and check if it works:

send_mass_mail((mail_tuple,))

Upvotes: 6

Related Questions