Mercurial > kallithea
changeset 4331:2655b2d46055
mail: improve logging - including always passing recipients as list as documented
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 10 Dec 2013 19:30:37 +0100 |
parents | 773980a93cdd |
children | 609e06b6c52f |
files | kallithea/lib/celerylib/tasks.py kallithea/lib/rcmail/smtp_mailer.py kallithea/model/notification.py kallithea/model/user.py |
diffstat | 4 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/celerylib/tasks.py Tue Dec 10 19:30:37 2013 +0100 +++ b/kallithea/lib/celerylib/tasks.py Tue Dec 10 19:30:37 2013 +0100 @@ -269,6 +269,7 @@ """ log = get_logger(send_email) DBS = get_session() + assert isinstance(recipients, list), recipients email_config = config subject = "%s %s" % (email_config.get('email_prefix', ''), subject) @@ -277,6 +278,7 @@ admins = [u.email for u in User.query() .filter(User.admin == True).all()] recipients = [email_config.get('email_to')] + admins + log.warning("recipients not specified for '%s' - sending to admins %s", subject, ' '.join(recipients)) mail_from = email_config.get('app_email_from', 'Kallithea') user = email_config.get('smtp_username') @@ -289,7 +291,9 @@ smtp_auth = email_config.get('smtp_auth') if not mail_server: - log.error("SMTP mail server not configured - cannot send mail") + log.error("SMTP mail server not configured - cannot send mail '%s' to %s", subject, ' '.join(recipients)) + log.warning("body:\n%s", body) + log.warning("html:\n%s", html_body) return False try:
--- a/kallithea/lib/rcmail/smtp_mailer.py Tue Dec 10 19:30:37 2013 +0100 +++ b/kallithea/lib/rcmail/smtp_mailer.py Tue Dec 10 19:30:37 2013 +0100 @@ -96,7 +96,7 @@ smtp_serv.login(self.user, self.passwd) smtp_serv.sendmail(msg.sender, msg.send_to, raw_msg.as_string()) - logging.info('MAIL SEND TO: %s' % recipients) + logging.info('MAIL SENT TO: %s' % recipients) try: smtp_serv.quit()
--- a/kallithea/model/notification.py Tue Dec 10 19:30:37 2013 +0100 +++ b/kallithea/model/notification.py Tue Dec 10 19:30:37 2013 +0100 @@ -126,7 +126,7 @@ email_body_html = EmailNotificationModel()\ .get_email_tmpl(type_, **kwargs) - run_task(tasks.send_email, rec.email, email_subject, email_body, + run_task(tasks.send_email, [rec.email], email_subject, email_body, email_body_html) return notif
--- a/kallithea/model/user.py Tue Dec 10 19:30:37 2013 +0100 +++ b/kallithea/model/user.py Tue Dec 10 19:30:37 2013 +0100 @@ -300,7 +300,7 @@ **{'user': user.short_contact, 'reset_url': link}) log.debug('sending email') - run_task(tasks.send_email, user_email, + run_task(tasks.send_email, [user_email], _("Password reset link"), body, body) log.info('send new password mail to %s' % user_email) else: @@ -329,7 +329,7 @@ raise Exception('unable to generate new password') pre_db = False - run_task(tasks.send_email, user_email, + run_task(tasks.send_email, [user_email], _('Your new password'), _('Your new Kallithea password:%s') % (new_passwd,)) log.info('send new password mail to %s' % user_email)