Commits

Edward "Hades" Toroshchin  committed 9cfaa0e

Handle error in sending an email to a user.

  • Participants
  • Parent commits 82fc2f4

Comments (0)

Files changed (1)

File djangobb_forum/views.py

             body = form.cleaned_data['body'] + u'\n %s %s [%s]' % (Site.objects.get_current().domain,
                                                                   request.user.username,
                                                                   request.user.email)
-            user.email_user(subject, body, request.user.email)
-            messages.success(request, _("Email send."))
+            try:
+                user.email_user(subject, body, request.user.email)
+                messages.success(request, _("Email send."))
+            except Exception:
+                messages.error(request, _("Email could not be sent."))
             return HttpResponseRedirect(reverse('djangobb:index'))
 
     elif 'mail_to' in request.GET: