Send email. It does not work. Please, fix it!
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 7 Nov 2008 15:23:03 +0000 (13:23 -0200)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 7 Nov 2008 15:23:03 +0000 (13:23 -0200)
eventos/views.py

index 5427973..6103045 100644 (file)
@@ -27,6 +27,7 @@ from django.template import RequestContext, Context, loader
 from eventos.models import Palestrante, Trabalho, TipoTrabalho, Trilha, Evento, Improve
 from eventos.forms import RegisterSpeaker
 from django.db.models import Q
+import smtplib
 
 forbidden = \
     HttpResponseForbidden('<h2>You are not allowed to do this action.<h2>')
@@ -322,6 +323,18 @@ def talk_improve(request, tid):
         if cleaned['trabalho'].evento.id != event.id:
             return forbidden
 
+        emails = [i.email for i in speakers]
+        user = cleaned['usuario'].get_full_name()
+        comments = cleaned['comentario']
+        msg = (u"From: emsl@minaslivre.org\r\nTo: %s\r\n"
+               u"Subject: Coment├írio em seu Trabalho EMSL 2008\r\n"
+               u"Content-Type: text/plain; charset=utf-8\r\n"
+               u"\r\n %s comentou seu trabalho.\r\n%s\r\r\n"
+               % (", ".join(emails), user, comments))
+        smtp = smtplib.SMTP("localhost")
+        smtp.sendmail("emsl@minaslivre.org", emails, str(msg.encode("utf8")))
+        smtp.quit()
+
         instance = form.save()
         return HttpResponseRedirect('/improve/%d/' % talk.id)