summaryrefslogtreecommitdiff
path: root/pykolab/itip/__init__.py
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-07-07 23:34:07 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-07-07 23:34:07 (GMT)
commit317c074fc70c972ed068c01e658925512abbc28a (patch)
treed636ce437c6f3ddfeb1428ebd8c45e2ef738a09b /pykolab/itip/__init__.py
parenta674289628249f45ec46c3096b1c476692943ff3 (diff)
downloadpykolab-317c074fc70c972ed068c01e658925512abbc28a.tar.gz
Catch potential exceptions while sending iTip replies; set recipient parstat=needs-action when saving new/re-scheduled invitations directly to calendar
Diffstat (limited to 'pykolab/itip/__init__.py')
-rw-r--r--pykolab/itip/__init__.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/pykolab/itip/__init__.py b/pykolab/itip/__init__.py
index f32cad4..43646df 100644
--- a/pykolab/itip/__init__.py
+++ b/pykolab/itip/__init__.py
@@ -197,13 +197,9 @@ def send_reply(from_address, itip_events, response_text, subject=None):
"""
import smtplib
- smtp = smtplib.SMTP("localhost", 10027)
conf = pykolab.getConf()
- if conf.debuglevel > 8:
- smtp.set_debuglevel(True)
-
if isinstance(itip_events, dict):
itip_events = [ itip_events ]
@@ -217,12 +213,25 @@ def send_reply(from_address, itip_events, response_text, subject=None):
if subject is not None:
subject = subject % { 'summary':event_summary, 'status':_(participant_status), 'name':attendee.get_name() }
- message = itip_event['xml'].to_message_itip(from_address,
- method="REPLY",
- participant_status=participant_status,
- message_text=message_text,
- subject=subject
- )
- smtp.sendmail(message['From'], message['To'], message.as_string())
+ try:
+ message = itip_event['xml'].to_message_itip(from_address,
+ method="REPLY",
+ participant_status=participant_status,
+ message_text=message_text,
+ subject=subject
+ )
+ except Exception, e:
+ log.error(_("Failed to compose iTip reply message: %r") % (e))
+ return
+
+ smtp = smtplib.SMTP("localhost", 10027)
+
+ if conf.debuglevel > 8:
+ smtp.set_debuglevel(True)
+
+ try:
+ smtp.sendmail(message['From'], message['To'], message.as_string())
+ except Exception, e:
+ log.error(_("SMTP sendmail error: %r") % (e))
smtp.quit()