diff --git a/kallithea/lib/celerylib/tasks.py b/kallithea/lib/celerylib/tasks.py --- a/kallithea/lib/celerylib/tasks.py +++ b/kallithea/lib/celerylib/tasks.py @@ -269,6 +269,7 @@ def send_email(recipients, subject, body """ 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 @@ def send_email(recipients, subject, body 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 @@ def send_email(recipients, subject, body 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: diff --git a/kallithea/lib/rcmail/smtp_mailer.py b/kallithea/lib/rcmail/smtp_mailer.py --- a/kallithea/lib/rcmail/smtp_mailer.py +++ b/kallithea/lib/rcmail/smtp_mailer.py @@ -96,7 +96,7 @@ class SmtpMailer(object): 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() diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py --- a/kallithea/model/notification.py +++ b/kallithea/model/notification.py @@ -126,7 +126,7 @@ class NotificationModel(BaseModel): 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 diff --git a/kallithea/model/user.py b/kallithea/model/user.py --- a/kallithea/model/user.py +++ b/kallithea/model/user.py @@ -300,7 +300,7 @@ class UserModel(BaseModel): **{'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 @@ class UserModel(BaseModel): 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)