Changeset View
Changeset View
Standalone View
Standalone View
wallace/module_invitationpolicy.py
Show First 20 Lines • Show All 1,103 Lines • ▼ Show 20 Lines | def send_update_notification(object, receiving_user, old=None, reply=True): | ||||
""" | """ | ||||
Send a (consolidated) notification about the current participant status to organizer | Send a (consolidated) notification about the current participant status to organizer | ||||
""" | """ | ||||
global auth | global auth | ||||
import smtplib | import smtplib | ||||
from email.MIMEText import MIMEText | from email.MIMEText import MIMEText | ||||
from email.Utils import formatdate | from email.Utils import formatdate | ||||
from email.header import Header | |||||
from email import charset | |||||
# encode unicode strings with quoted-printable | # encode unicode strings with quoted-printable | ||||
from email import charset | |||||
charset.add_charset('utf-8', charset.SHORTEST, charset.QP) | charset.add_charset('utf-8', charset.SHORTEST, charset.QP) | ||||
organizer = object.get_organizer() | organizer = object.get_organizer() | ||||
orgemail = organizer.email() | orgemail = organizer.email() | ||||
orgname = organizer.name() | orgname = organizer.name() | ||||
if reply: | if reply: | ||||
log.debug(_("Compose participation status summary for %s %r to user %r") % ( | log.debug(_("Compose participation status summary for %s %r to user %r") % ( | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | def send_update_notification(object, receiving_user, old=None, reply=True): | ||||
message_text += "\n" + _("*** This is an automated message. Please do not reply. ***") | message_text += "\n" + _("*** This is an automated message. Please do not reply. ***") | ||||
# compose mime message | # compose mime message | ||||
msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') | msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') | ||||
msg['To'] = receiving_user['mail'] | msg['To'] = receiving_user['mail'] | ||||
msg['Date'] = formatdate(localtime=True) | msg['Date'] = formatdate(localtime=True) | ||||
msg['Subject'] = utils.str2unicode(_('"%s" has been updated') % (object.get_summary())) | msg['Subject'] = utils.str2unicode(_('"%s" has been updated') % (object.get_summary())) | ||||
msg['From'] = utils.str2unicode('"%s" <%s>' % (orgname, orgemail) if orgname else orgemail) | msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '') | ||||
msg['From'].append("<%s>" % orgemail) | |||||
smtp = smtplib.SMTP("localhost", 10027) | smtp = smtplib.SMTP("localhost", 10027) | ||||
if conf.debuglevel > 8: | if conf.debuglevel > 8: | ||||
smtp.set_debuglevel(True) | smtp.set_debuglevel(True) | ||||
success = False | success = False | ||||
retries = 5 | retries = 5 | ||||
Show All 15 Lines | |||||
def send_cancel_notification(object, receiving_user, deleted=False): | def send_cancel_notification(object, receiving_user, deleted=False): | ||||
""" | """ | ||||
Send a notification about event/task cancellation | Send a notification about event/task cancellation | ||||
""" | """ | ||||
import smtplib | import smtplib | ||||
from email.MIMEText import MIMEText | from email.MIMEText import MIMEText | ||||
from email.Utils import formatdate | from email.Utils import formatdate | ||||
from email.header import Header | |||||
from email import charset | |||||
# encode unicode strings with quoted-printable | # encode unicode strings with quoted-printable | ||||
from email import charset | |||||
charset.add_charset('utf-8', charset.SHORTEST, charset.QP) | charset.add_charset('utf-8', charset.SHORTEST, charset.QP) | ||||
log.debug(_("Send cancellation notification for %s %r to user %r") % ( | log.debug(_("Send cancellation notification for %s %r to user %r") % ( | ||||
object.type, object.uid, receiving_user['mail'] | object.type, object.uid, receiving_user['mail'] | ||||
), level=8) | ), level=8) | ||||
organizer = object.get_organizer() | organizer = object.get_organizer() | ||||
orgemail = organizer.email() | orgemail = organizer.email() | ||||
Show All 23 Lines | def send_cancel_notification(object, receiving_user, deleted=False): | ||||
message_text += "\n\n" + _("*** This is an automated message. Please do not reply. ***") | message_text += "\n\n" + _("*** This is an automated message. Please do not reply. ***") | ||||
# compose mime message | # compose mime message | ||||
msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') | msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') | ||||
msg['To'] = receiving_user['mail'] | msg['To'] = receiving_user['mail'] | ||||
msg['Date'] = formatdate(localtime=True) | msg['Date'] = formatdate(localtime=True) | ||||
msg['Subject'] = utils.str2unicode(_('"%s" has been cancelled') % (object.get_summary())) | msg['Subject'] = utils.str2unicode(_('"%s" has been cancelled') % (object.get_summary())) | ||||
msg['From'] = utils.str2unicode('"%s" <%s>' % (orgname, orgemail) if orgname else orgemail) | msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '') | ||||
msg['From'].append("<%s>" % orgemail) | |||||
smtp = smtplib.SMTP("localhost", 10027) | smtp = smtplib.SMTP("localhost", 10027) | ||||
if conf.debuglevel > 8: | if conf.debuglevel > 8: | ||||
smtp.set_debuglevel(True) | smtp.set_debuglevel(True) | ||||
try: | try: | ||||
smtp.sendmail(orgemail, receiving_user['mail'], msg.as_string()) | smtp.sendmail(orgemail, receiving_user['mail'], msg.as_string()) | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |