Changeset - 2655b2d46055
[Not reviewed]
default
0 4 0
Mads Kiilerich - 12 years ago 2013-12-10 19:30:37
madski@unity3d.com
mail: improve logging - including always passing recipients as list as documented
4 files changed with 9 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/celerylib/tasks.py
Show inline comments
 
@@ -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:
kallithea/lib/rcmail/smtp_mailer.py
Show inline comments
 
@@ -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()
kallithea/model/notification.py
Show inline comments
 
@@ -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
kallithea/model/user.py
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)