Commit b64f71f0 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

astakos: do not catch send mail errors

The user should not be informed if for any reason
the server can not send an email.
parent 40f21b60
......@@ -225,35 +225,25 @@ def send_feedback(msg, data, user, email_template_name='im/feedback_mail.txt'):
'message': msg,
'data': data,
'user': user})
try:
send_mail(subject, content, from_email, recipient_list,
connection=get_connection())
except (SMTPException, socket.error) as e:
logger.exception(e)
raise SendFeedbackError()
else:
msg = 'Sent feedback from %s' % user.log_display
logger.log(LOGGING_LEVEL, msg)
send_mail(subject, content, from_email, recipient_list,
connection=get_connection())
msg = 'Sent feedback from %s' % user.log_display
logger.log(LOGGING_LEVEL, msg)
def send_change_email(
ec, request, email_template_name='registration/email_change_email.txt'):
try:
url = ec.get_url()
url = request.build_absolute_uri(url)
t = loader.get_template(email_template_name)
c = {'url': url, 'site_name': SITENAME,
'support': CONTACT_EMAIL, 'ec': ec}
from_email = settings.SERVER_EMAIL
send_mail(_(EMAIL_CHANGE_EMAIL_SUBJECT), t.render(Context(c)),
from_email, [ec.new_email_address],
connection=get_connection())
except (SMTPException, socket.error) as e:
logger.exception(e)
raise ChangeEmailError()
else:
msg = 'Sent change email for %s' % ec.user.log_display
logger.log(LOGGING_LEVEL, msg)
url = ec.get_url()
url = request.build_absolute_uri(url)
t = loader.get_template(email_template_name)
c = {'url': url, 'site_name': SITENAME,
'support': CONTACT_EMAIL, 'ec': ec}
from_email = settings.SERVER_EMAIL
send_mail(_(EMAIL_CHANGE_EMAIL_SUBJECT), t.render(Context(c)),
from_email, [ec.new_email_address],
connection=get_connection())
msg = 'Sent change email for %s' % ec.user.log_display
logger.log(LOGGING_LEVEL, msg)
def invite(inviter, email, realname):
......
......@@ -57,9 +57,6 @@ class Command(BaseCommand):
"User email already verified '%s'\n" % (user.email,))
continue
try:
activation_backend.send_user_verification_email(user)
except SendMailError, e:
raise CommandError(e.message)
activation_backend.send_user_verification_email(user)
self.stdout.write("Activation sent to '%s'\n" % (user.email,))
......@@ -35,8 +35,6 @@ from django.core.management.base import BaseCommand, CommandError
from django.db.utils import IntegrityError
from django.db import transaction
from astakos.im.functions import SendMailError
from ._common import get_user
......@@ -62,10 +60,7 @@ class Command(BaseCommand):
try:
inviter.invite(email, realname)
self.stdout.write("Invitation sent to '%s'\n" % (email,))
except SendMailError, e:
transaction.rollback()
raise CommandError(e.message)
except IntegrityError, e:
except IntegrityError:
transaction.rollback()
raise CommandError(
"There is already an invitation for %s" % (email,))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment