django EmailMultiAlternatives - / ...的ValueError需要多于1个值才能解包

时间:2011-02-19 22:09:23

标签: django

我不知道为什么我会遇到这个错误。这是代码,我几乎可以肯定问题是

 tekst = "Your credetials " + login + haslo + ". Activation key " + klucz
 contex = Context({"klucz" : klucz,"login" : login,"haslo" : haslo})
 template = loader.get_template("aktywacja/email_aktywacyjny.html")
 html = template.render(contex)
 email = EmailMultiAlternatives("Welcome",tekst,"Team",[email])
 email.attach_alternative(html,"text/html")
 email.send()

变量有效,并且来自is_valid()方法之后的形式。 这是追溯:

Traceback:
File "D:\Programy\python27\lib\site-packages\django-1.2.4-py2.7.egg\django\core\handlers\base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Artur\Desktop\\views.py" in rejestracja
  50.                 email.send()
File "D:\Programy\python27\lib\site-packages\django-1.2.4-py2.7.egg\django\core\mail\message.py" in send
  179.         return self.get_connection(fail_silently).send_messages([self])
File "D:\Programy\python27\lib\site-packages\django-1.2.4-py2.7.egg\django\core\mail\backends\smtp.py" in send_messages
  85.                 sent = self._send(message)
File "D:\Programy\python27\lib\site-packages\django-1.2.4-py2.7.egg\django\core\mail\backends\smtp.py" in _send
  103.         from_email = self._sanitize(email_message.from_email)
File "D:\Programy\python27\lib\site-packages\django-1.2.4-py2.7.egg\django\core\mail\backends\smtp.py" in _sanitize
  95.         name, domain = email.split('@', 1)

任何人都可以帮忙吗? 最诚挚的问候

1 个答案:

答案 0 :(得分:2)

错误来自于尝试与@分开并失败。

email=EmailMultiAlternatives("Welcome",tekst,"Team",[email]) 

"Team"需要是电子邮件地址。

>>> name, domain = 'Team'.split('@', 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: need more than 1 value to unpack
>>>