Ignore:
Timestamp:
Jul 24, 2009 11:08:58 PM (15 years ago)
Author:
jcbrand
Message:

Log email errors, so that the report abuse form still closes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qPloneComments/branches/jcbrand-abuseFeature/utils.py

    r943 r1161  
     1import logging 
     2import smtplib 
    13from Products.CMFPlone import MessageFactory 
    24from Products.CMFCore.utils import getToolByName 
     5from Products.CMFPlone import PloneMessageFactory as _ 
     6 
     7log = logging.getLogger('Products.qPloneComments.utils.py') 
    38 
    49# Get apropriate property from (propery_sheeet) configlet 
     
    201206        site_props = context.portal_properties.site_properties 
    202207        host = p_utils.getMailHost() 
    203         host.secureSend(msg, user_email, admin_email, 
    204                         subject = subject, 
    205                         subtype = 'plain', 
    206                         debug = False, 
    207                         charset = site_props.getProperty('default_charset', 'utf-8'), 
    208                         From = admin_email) 
     208        try: 
     209            host.secureSend(msg, user_email, admin_email, 
     210                            subject = subject, 
     211                            subtype = 'plain', 
     212                            debug = False, 
     213                            charset = site_props.getProperty('default_charset', 'utf-8'), 
     214                            From = admin_email) 
     215        except smtplib.SMTPRecipientsRefused: 
     216            log.error(_('SMTPRecipientsRefused: Could not send the email' 
     217            'notification. Have you configured an email server for Plone?')) 
     218             
     219 
    209220 
    210221def setStatusMsg(state, context, msg): 
Note: See TracChangeset for help on using the changeset viewer.