def alertCreation(self, confs): conf = confs[0] fromAddr = Config.getInstance().getSupportEmail() addrs = [ Config.getInstance().getSupportEmail() ] eventType = conf.getType() if eventType == "conference": type = "conference" elif eventType == "meeting": type = "meeting" else: type = "lecture" chair = "" if conf.getChairmanText() != "": chair = conf.getChairmanText() else: for c in conf.getChairList(): chair += c.getFullName() + "; " subject = "New %s in indico (%s)" % (type,conf.getId()) if conf.getRoom() != None: room = conf.getRoom().getName() else: room = "" text = """ _Category_ %s _Title_ %s _Speaker/Chair_ %s _Room_ %s _Description_ %s _Creator_ %s (%s)"""%(conf.getOwner().getTitle(), conf.getTitle(), chair, room, conf.getDescription(), conf.getCreator().getFullName(), conf.getCreator().getId()) if len(confs) == 1: text += """ _Date_ %s -> %s _Access_ %s""" % ( conf.getAdjustedStartDate(), conf.getAdjustedEndDate(), urlHandlers.UHConferenceDisplay.getURL(conf)) else: i = 1 for c in confs: text += """ _Date%s_ %s -> %s _Access%s_ %s """ % (i,c.getAdjustedStartDate(), c.getAdjustedEndDate(), i,urlHandlers.UHConferenceDisplay.getURL(c)) i+=1 msg = ("Content-Type: text/plain; charset=\"utf-8\"\r\nFrom: %s\r\nReturn-Path: %s\r\nTo: %s\r\nCc: \r\nSubject: %s\r\n\r\n"%(fromAddr, fromAddr, addrs, subject)) msg = msg + text maildata = { "fromAddr": fromAddr, "toList": addrs, "subject": subject, "body": text } GenericMailer.send(maildata) # Category notification if conf.getOwner().getNotifyCreationList() != "": addrs2 = [ conf.getOwner().getNotifyCreationList() ] maildata2 = { "fromAddr": fromAddr, "toList": addrs2, "subject": subject, "body": text } GenericMailer.send(maildata2)
def send(self): url = urlHandlers.UHConfActiveAccount.getURL( self._conf) if self._conf else urlHandlers.UHActiveAccount.getURL( ) text = _("""Welcome to Indico, You have created a new account on the Indico conference management system. In order to activate your new account and being able to be authenticated by the system, please open on your web browser the following URL: %s?userId=%s&key=%s Once you've done it, your account will be fully operational so you can log in and start using the system normally. Thank you for using our system. """)%(url, self._user.getId(), \ self._user.getKey()) maildata = { "fromAddr": "Indico Mailer <%s>" % Config.getInstance().getNoReplyEmail(), "toList": [self._user.getEmail()], "subject": _("[%s] Confirmation request") % getSubjectIndicoTitle(), "body": text } GenericMailer.send(GenericNotification(maildata))
def _send_confirmation(self, email): token_storage = GenericCache('confirm-email') data = {'email': email, 'user_id': self.user.id} token = make_unique_token(lambda t: not token_storage.get(t)) token_storage.set(token, data, 24 * 3600) GenericMailer.send(make_email(email, template=get_template_module('users/emails/verify_email.txt', user=self.user, email=email, token=token)))
def _process(self): canManageRegistration = self._conf.canManageRegistration(self._getUser()) if not canManageRegistration and not self._regForm.isActivated(): p = registrationForm.WPRegFormInactive(self, self._conf) return p.display() params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams(params, 'email') if email is None: raise FormValuesError(_("An email address has to be set in order to make the registration in the event.")) elif not validMail(email, False): raise FormValuesError(_("The given email address is not valid.")) matchedUsers = AvatarHolder().match({"email": email}, exact=1) if matchedUsers: user = matchedUsers[0] else: user = None # Check if the user can register if not canManageRegistration: # normal user registering. Managers can. if self._conf.getRegistrationForm().isFull(): self._redirect(urlHandlers.UHConfRegistrationFormDisplay.getURL(self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): p = registrationForm.WPRegistrationFormClosed(self, self._conf) return p.display() if user is None: if self._conf.hasRegistrantByEmail(email): raise FormValuesError("There is already a user with the email \"%s\". Please choose another one" % email) else: if user.isRegisteredInConf(self._conf) or self._conf.hasRegistrantByEmail(email): if canManageRegistration: raise FormValuesError("There is already a user with the email \"%s\". Please choose another one" % email) else: raise FormValuesError("You have already registered with the email address \"%s\". If you need to modify your registration, please contact the managers of the conference." % email) rp = registration.Registrant() self._conf.addRegistrant(rp, user) rp.setValues(self._getRequestParams(), user) if user is not None: user.addRegistrant(rp) rp.setAvatar(user) # This creates the email to the new registrant and SENDS the email to the organizers if necessary... WTF. email = self._regForm.getNotification().createEmailNewRegistrant(self._regForm, rp) if self._regForm.isSendRegEmail() and rp.getEmail().strip(): modEticket = self._conf.getRegistrationForm().getETicket() if modEticket.isEnabled() and modEticket.isAttachedToEmail(): attachment = { 'name': "{0}-Ticket.pdf".format(self._target.getTitle()), 'binary': TicketToPDF(self._target, rp).getPDFBin(), } email["attachments"] = [attachment] GenericMailer.send(email) if canManageRegistration and user != self._getUser(): self._redirect(RHRegistrantListModif._uh.getURL(self._conf)) else: self._redirect(urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp))
def send( self ): minfo = HelperMaKaCInfo.getMaKaCInfoInstance() name = self._user.getStraightFullName() text = """Dear Administrator, %s has created a new account in Indico. <%s> """ % (name,urlHandlers.UHUserDetails.getURL( self._user )) maildata = { "fromAddr": "Indico Mailer<%s>" % minfo.getSupportEmail(), "toList": minfo.getAdminEmails(), "subject": _("[Indico] New account creation"), "body": text } GenericMailer.send(GenericNotification(maildata))
def _process(self): canManageRegistration = self._conf.canManageRegistration(self._getUser()) if not canManageRegistration and not self._regForm.isActivated(): p = registrationForm.WPRegFormInactive(self, self._conf) return p.display() params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams(params, "email") if email is None: raise FormValuesError(_("An email address has to be set in order to make the registration in the event.")) elif not validMail(email, False): raise FormValuesError(_("The given email address is not valid.")) matchedUsers = AvatarHolder().match({"email": email}, exact=1) if matchedUsers: user = matchedUsers[0] else: user = None # Check if the user can register if not canManageRegistration: # normal user registering. Managers can. if self._conf.getRegistrationForm().isFull(): self._redirect(urlHandlers.UHConfRegistrationFormDisplay.getURL(self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): p = registrationForm.WPRegistrationFormClosed(self, self._conf) return p.display() if user is None: if self._conf.hasRegistrantByEmail(email): raise FormValuesError('There is already a user with the email "%s". Please choose another one' % email) else: if user.isRegisteredInConf(self._conf): self._redirect(urlHandlers.UHConfRegistrationForm.getURL(self._conf)) return if self._conf.hasRegistrantByEmail(email): if canManageRegistration: raise FormValuesError( 'There is already a user with the email "%s". Please choose another one' % email ) else: raise FormValuesError( 'You have already registered with the email address "%s". If you need to modify your registration, please contact the managers of the conference.' % email ) rp = registration.Registrant() self._conf.addRegistrant(rp) rp.setValues(self._getRequestParams(), user) rp.setSessionBillingEnabled(self._regForm.getSessionsForm().getType() != "2priorities") if user is not None: user.addRegistrant(rp) rp.setAvatar(user) # avoid multiple sending in case of db conflict email = self._regForm.getNotification().createEmailNewRegistrant(self._regForm, rp) if email: GenericMailer.send(email) if not canManageRegistration: self._redirect(urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp)) else: self._redirect(RHRegistrantListModif._uh.getURL(self._conf))
def approve(self, sendNotification=True): """ Approve the room blocking and reject colloding bookings """ self.active = True # If the blocking has not been saved yet, don't reject anything - will be done later in block.insert() if self.block.id is None: return # Create a fake reservation candidate to find bookings colliding with the blocking candResv = Location.parse(self.room.locationName).factory.newReservation() candResv.room = self.room candResv.startDT = datetime.datetime.combine(self.block.startDate, datetime.time()) candResv.endDT = datetime.datetime.combine(self.block.endDate, datetime.time(23, 59)) candResv.repeatability = RepeatabilityEnum.daily candResv.isConfirmed = None collisions = candResv.getCollisions() rejectionReason = "Conflict with blocking %s: %s" % (self.block.id, self.block.message) emailsToBeSent = [] for coll in collisions: collResv = coll.withReservation if collResv.isRejected: continue elif self.block.canOverride(collResv.createdByUser(), self.room): continue elif collResv.repeatability is None or ( collResv.startDT.date() >= self.block.startDate and collResv.endDT.date() <= self.block.endDate ): collResv.rejectionReason = rejectionReason collResv.reject() # Just sets isRejected = True collResv.update() emails = collResv.notifyAboutRejection() emailsToBeSent += emails # Add entry to the booking history info = [] info.append("Booking rejected") info.append("Reason: '%s'" % collResv.rejectionReason) histEntry = ResvHistoryEntry(self.block.createdByUser, info, emails) collResv.getResvHistory().addHistoryEntry(histEntry) else: # repeatable -> only reject the specific days rejectDate = coll.startDT.date() collResv.excludeDay(rejectDate, unindex=True) collResv.update() emails = collResv.notifyAboutRejection(date=rejectDate, reason=rejectionReason) emailsToBeSent += emails # Add entry to the booking history info = [] info.append("Booking occurence of the %s rejected" % rejectDate.strftime("%d %b %Y")) info.append("Reason: '%s'" % rejectionReason) histEntry = ResvHistoryEntry(self.block.createdByUser, info, emails) collResv.getResvHistory().addHistoryEntry(histEntry) if sendNotification: emailsToBeSent += RoomBlockingNotification.blockingRequestProcessed(self) for email in emailsToBeSent: GenericMailer.send(GenericNotification(email))
def send( notification ): info = HelperMaKaCInfo.getMaKaCInfoInstance() fromAddr = "%s <%s>"%(info.getTitle(), info.getSupportEmail()) toAddr = str(notification.getDestination().getEmail()) text = """%s -- Indico project <http://cern.ch/indico> """%(notification.getMsg()) maildata = { "fromAddr": fromAddr, "toList": [toAddr], "subject": "[Indico] %s"%notification.getSubject(), "body": text } GenericMailer.send(GenericNotification(maildata))
def wrapper(*args, **kwargs): mails = fn(*args, **kwargs) if mails is None: return if isinstance(mails, GeneratorType): mails = list(mails) elif not isinstance(mails, list): mails = [mails] for mail in filter(None, mails): GenericMailer.send(GenericNotification(mail))
def _send_confirmation(email, salt, endpoint, template, template_args=None, url_args=None, data=None): template_args = template_args or {} url_args = url_args or {} token = secure_serializer.dumps(data or email, salt=salt) url = url_for(endpoint, token=token, _external=True, _secure=True, **url_args) template_module = get_template_module(template, email=email, url=url, **template_args) GenericMailer.send(make_email(email, template=template_module)) flash(_('We have sent you a verification email. Please check your mailbox within the next hour and open ' 'the link in that email.')) return redirect(url_for(endpoint, **url_args))
def _sendResultEmail(cls, maxDate, previousTotal, newTotal, error, attainedDate): """ Sends a mail detailing how the operation went """ if MailTools.needToSendEmails('Vidyo'): try: notification = VidyoCleaningDoneNotification(maxDate, previousTotal, newTotal, error, attainedDate) GenericMailer.send(notification) except Exception, e: Logger.get('Vidyo').error( """Could not send VidyoCleaningDoneNotification, exception: %s""" % str(e))
def approve(self, sendNotification=True): """ Approve the room blocking and reject colloding bookings """ self.active = True # If the blocking has not been saved yet, don't reject anything - will be done later in block.insert() if self.block.id is None: return # Create a fake reservation candidate to find bookings colliding with the blocking candResv = Location.parse(self.room.locationName).factory.newReservation() candResv.room = self.room candResv.startDT = datetime.datetime.combine(self.block.startDate, datetime.time()) candResv.endDT = datetime.datetime.combine(self.block.endDate, datetime.time(23, 59)) candResv.repeatability = RepeatabilityEnum.daily candResv.isConfirmed = None collisions = candResv.getCollisions() rejectionReason = "Conflict with blocking %s: %s" % (self.block.id, self.block.message) emailsToBeSent = [] for coll in collisions: collResv = coll.withReservation if collResv.isRejected: continue elif self.block.canOverride(collResv.createdByUser(), self.room): continue elif (collResv.repeatability is None or (collResv.startDT.date() >= self.block.startDate and collResv.endDT.date() <= self.block.endDate)): collResv.rejectionReason = rejectionReason collResv.reject() # Just sets isRejected = True collResv.update() emails = collResv.notifyAboutRejection() emailsToBeSent += emails # Add entry to the booking history info = [] info.append("Booking rejected") info.append("Reason: '%s'" % collResv.rejectionReason) histEntry = ResvHistoryEntry(self.block.createdByUser, info, emails) collResv.getResvHistory().addHistoryEntry(histEntry) else: # repeatable -> only reject the specific days rejectDate = coll.startDT.date() collResv.excludeDay(rejectDate, unindex=True) collResv.update() emails = collResv.notifyAboutRejection(date=rejectDate, reason=rejectionReason) emailsToBeSent += emails # Add entry to the booking history info = [] info.append("Booking occurence of the %s rejected" % rejectDate.strftime("%d %b %Y")) info.append("Reason: '%s'" % rejectionReason) histEntry = ResvHistoryEntry(self.block.createdByUser, info, emails) collResv.getResvHistory().addHistoryEntry(histEntry) if sendNotification: emailsToBeSent += RoomBlockingNotification.blockingRequestProcessed(self) for email in emailsToBeSent: GenericMailer.send(GenericNotification(email))
def send( self ): minfo=HelperMaKaCInfo.getMaKaCInfoInstance() text = _("""Welcome to Indico, Your registration has been accepted by the site administrator. You can now login using the following username: %s Thank you for using Indico. """)%(self._user.getIdentityList()[0].getLogin()) maildata = { "fromAddr": "Indico Mailer<%s>"%minfo.getSupportEmail(), "toList": [self._user.getEmail()], "subject": _("[%s] Registration accepted")%getSubjectIndicoTitle(), "body": text } GenericMailer.send(GenericNotification(maildata))
def send(addto, addcc, addfrom, subject, body): addto = addto.replace("\r\n","") tolist = addto.split(",") cclist = addcc.split(",") maildata = { "fromAddr": addfrom, "toList": tolist, "ccList": cclist, "subject": subject, "body": body } GenericMailer.send(GenericNotification(maildata))
def send(addto, addcc, addfrom, subject, body): addto = addto.replace("\r\n", "") tolist = addto.split(",") cclist = addcc.split(",") maildata = { "fromAddr": addfrom, "toList": tolist, "ccList": cclist, "subject": subject, "body": body } GenericMailer.send(GenericNotification(maildata))
def send_login_info(user, event=None): token_storage = GenericCache('resetpass') endpoint = 'event.confLogin-resetPassword' if event else 'user.signIn-resetPassword' idList = user.getIdentityList() logins = [] for id in idList: if not hasattr(id, 'setPassword'): config = Config.getInstance() extra_message = config.getAuthenticatorConfigById(id.getAuthenticatorTag()).get("ResetPasswordMessage") msg = _("Sorry, you are using an externally managed account (%s) to login into Indico.") % id.getLogin() if extra_message: msg += "\n" + extra_message logins.append({ 'tag': id.getAuthenticatorTag(), 'login': id.getLogin(), 'error': msg }) else: tag = id.getAuthenticatorTag() login = id.getLogin() data = {'tag': tag, 'login': login} token = str(uuid.uuid4()) while token_storage.get(token): token = str(uuid.uuid4()) token_storage.set(token, data, 6*3600) url = url_for(endpoint, event, token=token, _external=True, _secure=True) logins.append({ 'tag': tag, 'login': login, 'link': url }) if not logins: url = urlHandlers.UHUserDetails.getURL(user) text = _("Sorry, we did not find your login.\nPlease, create one here:\n%s") % url else: text = _("You can use the following links within the next six hours to reset your password.") for entry in logins: text += "\n\n==================\n" if 'link' in entry: text += _("Click below to reset your password for the %s login '%s':\n") % (entry['tag'], entry['login']) text += entry['link'] else: text += entry['error'] text += "\n==================\n" maildata = { "fromAddr": "Indico Mailer <%s>" % Config.getInstance().getNoReplyEmail(), "toList": [user.getEmail()], "subject": _("[%s] Login Information") % getSubjectIndicoTitle(), "body": text } GenericMailer.send(GenericNotification(maildata))
def reject(self, user=None, reason=None, sendNotification=True): """ Reject the room blocking """ self.active = False if reason: self.rejectionReason = reason if user: self.rejectedBy = user.getFullName() emails = RoomBlockingNotification.blockingRequestProcessed(self) for email in emails: GenericMailer.send(GenericNotification(email))
def _process( self ): canManageRegistration = self._conf.canManageRegistration(self._getUser()) if not canManageRegistration and not self._regForm.isActivated(): p = registrationForm.WPRegFormInactive( self, self._conf ) return p.display() params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams(params, 'email') if email is None: raise FormValuesError(_("An email address has to be set in order to make the registration in the event.")) elif not validMail(email, False): raise FormValuesError(_("The given email address is not valid.")) matchedUsers = AvatarHolder().match({"email": email}, exact=1) if matchedUsers: user = matchedUsers[0] else: user = None # Check if the user can register if not canManageRegistration: # normal user registering. Managers can. if self._conf.getRegistrationForm().isFull(): self._redirect(urlHandlers.UHConfRegistrationFormDisplay.getURL(self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): p = registrationForm.WPRegistrationFormClosed(self, self._conf) return p.display() if user is None: if self._conf.hasRegistrantByEmail(email): raise FormValuesError("There is already a user with the email \"%s\". Please choose another one"%email) else: if user.isRegisteredInConf(self._conf): self._redirect(urlHandlers.UHConfRegistrationForm.getURL(self._conf)) return if self._conf.hasRegistrantByEmail(email): if canManageRegistration: raise FormValuesError("There is already a user with the email \"%s\". Please choose another one"%email) else: raise FormValuesError("You have already registered with the email address \"%s\". If you need to modify your registration, please contact the managers of the conference."%email) rp = registration.Registrant() self._conf.addRegistrant(rp) rp.setValues(self._getRequestParams(), user) rp.setSessionBillingEnabled(self._regForm.getSessionsForm().getType() != "2priorities") if user is not None: user.addRegistrant(rp) rp.setAvatar(user) # avoid multiple sending in case of db conflict email = self._regForm.getNotification().createEmailNewRegistrant(self._regForm, rp) if email: GenericMailer.send(email) if not canManageRegistration: self._redirect(urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp)) else: self._redirect(RHRegistrantListModif._uh.getURL(self._conf))
def _sendResultEmail(cls, maxDate, previousTotal, newTotal, error, attainedDate): """ Sends a mail detailing how the operation went """ if MailTools.needToSendEmails('Vidyo'): try: notification = VidyoCleaningDoneNotification( maxDate, previousTotal, newTotal, error, attainedDate) GenericMailer.send(notification) except Exception, e: Logger.get('Vidyo').error( """Could not send VidyoCleaningDoneNotification, exception: %s""" % str(e))
def send(self): text = _("""Dear user, Your account has been disabled by the site administrator. """) maildata = { "fromAddr": "Indico Mailer<%s>" % Config.getInstance().getNoReplyEmail(), "toList": [self._user.getEmail()], "subject": _("[%s] Account disabled") % getSubjectIndicoTitle(), "body": text } GenericMailer.send(GenericNotification(maildata))
def sendParticipantsEmail(self, operation): params = self.getBookingParams() try: if params.has_key('sendAttendeesEmail') and params['sendAttendeesEmail'][0].lower() == 'yes': recipients = [] for k in self._participants.keys(): recipients.append( self._participants[k]._email ) if len(recipients)>0: if operation == 'remove': notification = WebExParticipantNotification( self,recipients, operation ) GenericMailer.send( notification ) else: notification = WebExParticipantNotification( self,recipients, operation, additionalText="This is a WebEx meeting invitation.<br/><br/>" ) GenericMailer.send( notification ) if params.has_key('sendCreatorEmail') and params['sendCreatorEmail'][0].lower() == 'yes': recipients = MailTools.getManagersEmailList(self.getConference(), 'WebEx') notification = WebExParticipantNotification( self,recipients, operation, additionalText="Dear event manager:<br/><br/>\n\n " ) GenericMailer.send( notification ) if params.has_key('sendSelfEmail') and params['sendSelfEmail'][0].lower() == 'yes' and params.has_key("loggedInEmail") and params["loggedInEmail"] != "": recipients = [ params["loggedInEmail"] ] notification = WebExParticipantNotification( self,recipients, operation, additionalText="You are receiving this email because you requested it when creating a WebEx booking via Indico.<br/><br/>\n\n " ) GenericMailer.send( notification ) except Exception,e: Logger.get('WebEx').error( """Could not send participant email for booking with id %s of event with id %s, operation %s, exception: %s""" % (self.getId(), self.getConference().getId(), operation, str(e))) Logger.get('WebEx').error( MailTools.getManagersEmailList(self.getConference(), 'WebEx') ) self._warning = _("The operation appears to have been successful, however there was an error in sending the emails to participants: %s" % str(e) )
def notifyOwners(self): """ Send emails to all room owners who need to approve blockings. Every owner gets only a single email, containing all the affected rooms. """ notify_owners = defaultdict(list) for rb in self.blockedRooms: if rb.active is None and not rb.notificationSent: notify_owners[rb.room.responsibleId].append(rb) rb.notificationSent = True emails = [] for ownerId, roomBlockings in notify_owners.iteritems(): emails += RoomBlockingNotification.requestConfirmation(AvatarHolder().getById(ownerId), self, roomBlockings) for email in emails: GenericMailer.send(GenericNotification(email))
def send( self ): minfo = HelperMaKaCInfo.getMaKaCInfoInstance() name = self._user.getStraightFullName() text = """ Dear Administrator, %s has created a new account in Indico. In order to activate it, please go to this URL: <%s> """% (name,urlHandlers.UHUserDetails.getURL( self._user )) maildata = { "fromAddr": "Indico Mailer <%s>" % Config.getInstance().getNoReplyEmail(), "toList": minfo.getAdminEmails(), "subject": _("[Indico] New account request from %s") % name, "body": text } GenericMailer.send(GenericNotification(maildata))
def send( self ): text = _("""Welcome to Indico, You have created a new account on the Indico conference management system. In order to activate your new account and being able to be authenticated by the system, please open on your web browser the following URL: %s?userId=%s&key=%s Once you've done it, your account will be fully operational so you can log in and start using the system normally. Thank you for using our system. """)%(urlHandlers.UHActiveAccount.getURL(), \ self._user.getId(), \ self._user.getKey()) maildata = { "fromAddr": "Indico Mailer<%s>"%HelperMaKaCInfo.getMaKaCInfoInstance().getSupportEmail(), "toList": [self._user.getEmail()], "subject": _("[%s] Confirmation request")%getSubjectIndicoTitle(), "body": text } GenericMailer.send(GenericNotification(maildata))
def send_email(email, event=None, module="", user=None, skip_queue=False): """Sends an email created by :func:`make_email`. :param email: The email object returned by :func:`make_email` :param event: If specified, the email will be saved in that event's log :param module: The module name to show in the email log :param user: The user to show in the email log :param skip_queue: If true, the email will be sent immediately instead of being queued until after commit even while inside a RH context """ if event is not None: GenericMailer.sendAndLog(email, event, module=module, user=user, skipQueue=skip_queue) else: GenericMailer.send(email, skipQueue=skip_queue)
class sendLoginInfo: def __init__( self, user ): self._user = user def send (self ): idList = self._user.getIdentityList() logins = [] for id in idList: try: pw = id.password except AttributeError, e: pw = _(" Sorry, you are using your NICE credentials to login into Indico. Please contact the CERN helpdesk in case you do not remember your password ([email protected]).") logins.append( [id.getAuthenticatorTag(), id.getLogin(),pw]) if logins == []: text = _("Sorry, we did not find your login.\nPlease, create one here:\n%s")%urlHandlers.UHUserDetails.getURL(self._user) else: text = _("Please, find your login and password:"******"\n\n==================\n" text += _("system:%s\n")%l[0] text += _("Login:%s\n")%l[1] text += _("Password:%s\n")%l[2] text += "==================\n" maildata = { "fromAddr": "Indico Mailer<%s>"%HelperMaKaCInfo.getMaKaCInfoInstance().getSupportEmail(), "toList": [self._user.getEmail()], "subject": _("[%s] Login Information")%getSubjectIndicoTitle(), "body": text } GenericMailer.send(GenericNotification(maildata))
def send(notification, fromAddress=""): info = HelperMaKaCInfo.getMaKaCInfoInstance() if fromAddress.strip() == "": fromAddr = "%s <%s>"%(info.getTitle(), Config.getInstance().getSupportEmail()) else: fromAddr = notification.getFromAddr() toAddr = str(notification.getDestination().getEmail()) text = """%s -- Indico project <http://indico-software.org/> """%(notification.getMsg()) maildata = { "fromAddr": fromAddr, "toList": [toAddr], "subject": "[Indico] %s" % notification.getSubject(), "body": text } GenericMailer.send(GenericNotification(maildata))
def send( notification, fromAddress="" ): info = HelperMaKaCInfo.getMaKaCInfoInstance() if fromAddress.strip() == "": fromAddr = "%s <%s>"%(info.getTitle(), Config.getInstance().getSupportEmail()) else: fromAddr = notification.getFromAddr() toAddr = str(notification.getDestination().getEmail()) text = """%s -- Indico project <http://indico-software.org/> """%(notification.getMsg()) maildata = { "fromAddr": fromAddr, "toList": [toAddr], "subject": "[Indico] %s" % notification.getSubject(), "body": text } GenericMailer.send(GenericNotification(maildata))
def sendParticipantsEmail(self, operation): params = self.getBookingParams() try: if params.has_key('sendAttendeesEmail') and params[ 'sendAttendeesEmail'][0].lower() == 'yes': recipients = [] for k in self._participants.keys(): recipients.append(self._participants[k]._email) if len(recipients) > 0: if operation == 'remove': notification = WebExParticipantNotification( self, recipients, operation) GenericMailer.send(notification) else: notification = WebExParticipantNotification( self, recipients, operation, additionalText= "This is a WebEx meeting invitation.<br/><br/>") GenericMailer.send(notification) if params.has_key('sendCreatorEmail') and params[ 'sendCreatorEmail'][0].lower() == 'yes': recipients = MailTools.getManagersEmailList( self.getConference(), 'WebEx') notification = WebExParticipantNotification( self, recipients, operation, additionalText="Dear event manager:<br/><br/>\n\n ") GenericMailer.send(notification) if params.has_key('sendSelfEmail') and params['sendSelfEmail'][ 0].lower() == 'yes' and params.has_key( "loggedInEmail") and params["loggedInEmail"] != "": recipients = [params["loggedInEmail"]] notification = WebExParticipantNotification( self, recipients, operation, additionalText= "You are receiving this email because you requested it when creating a WebEx booking via Indico.<br/><br/>\n\n " ) GenericMailer.send(notification) except Exception, e: Logger.get('WebEx').error( """Could not send participant email for booking with id %s of event with id %s, operation %s, exception: %s""" % (self.getId(), self.getConference().getId(), operation, str(e))) Logger.get('WebEx').error( MailTools.getManagersEmailList(self.getConference(), 'WebEx')) self._warning = _( "The operation appears to have been successful, however there was an error in sending the emails to participants: %s" % str(e))
def _send(action, user, plugin, event, room, subject, body): to_list = {user.email} cc_list = plugin.get_notification_cc_list(action, room, event) - to_list bcc_list = plugin.get_notification_bcc_list(action, room, event) - cc_list - to_list notification = { 'content-type': 'text/html', 'fromAddr': Config.getInstance().getNoReplyEmail(), 'toList': to_list, 'ccList': cc_list, 'bccList': bcc_list, 'subject': subject, 'body': body } if event is None: GenericMailer.send(GenericNotification(notification)) else: GenericMailer.sendAndLog(GenericNotification(notification), event, plugin.name)
def _send(action, user, plugin, event, room, subject, body): to_list = {user.getEmail()} cc_list = plugin.get_notification_cc_list(action, room, event) - to_list bcc_list = plugin.get_notification_bcc_list(action, room, event) - cc_list - to_list notification = { 'content-type': 'text/html', 'fromAddr': Config.getInstance().getNoReplyEmail(), 'toList': to_list, 'ccList': cc_list, 'bccList': bcc_list, 'subject': subject, 'body': body } if event is None: GenericMailer.send(GenericNotification(notification)) else: GenericMailer.sendAndLog(GenericNotification(notification), event, plugin.name)
def send(self): minfo = HelperMaKaCInfo.getMaKaCInfoInstance() name = self._user.getStraightFullName() text = """ Dear Administrator, %s has created a new account in Indico. In order to activate it, please go to this URL: <%s> """ % (name, urlHandlers.UHUserDetails.getURL(self._user)) maildata = { "fromAddr": "Indico Mailer <%s>" % Config.getInstance().getNoReplyEmail(), "toList": minfo.getAdminEmails(), "subject": _("[Indico] New account request from %s") % name, "body": text } GenericMailer.send(GenericNotification(maildata))
def send_email(email, event=None, module='', user=None, skip_queue=False): """Sends an email created by :func:`make_email`. :param email: The email object returned by :func:`make_email` :param event: If specified, the email will be saved in that event's log :param module: The module name to show in the email log :param user: The user to show in the email log :param skip_queue: If true, the email will be sent immediately instead of being queued until after commit even while inside a RH context """ if event is not None: GenericMailer.sendAndLog(email, event, module=module, user=user, skipQueue=skip_queue) else: GenericMailer.send(email, skipQueue=skip_queue)
def sendReservationStartStopNotification(resv, which, occurrence): if which == 'start' and resv.room.resvStartNotification: msg = getRoomBookingOption('startNotificationEmail') subject = getRoomBookingOption('startNotificationEmailSubject') elif which == 'end' and resv.room.resvEndNotification: msg = getRoomBookingOption('endNotificationEmail') subject = getRoomBookingOption('endNotificationEmailSubject') else: return av = resv.bookedForUser if av: bookedForDetails = '%s %s\n%s' % (av.getFullName(), av.getPersonId() or '', av.getEmail()) else: bookedForDetails = '%s\n%s' % (resv.bookedForName, resv.contactEmail) msgArgs = { 'bookedForUser': bookedForDetails, 'roomName': resv.room.getFullName(), 'roomAtts': resv.room.customAtts, 'bookingStart': formatDateTime(resv.startDT), 'bookingEnd': formatDateTime(resv.endDT), 'occStart': formatDateTime(occurrence.startDT), 'occEnd': formatDateTime(occurrence.endDT), 'detailsLink': urlHandlers.UHRoomBookingBookingDetails.getURL(resv) } recipients = set() recipients.update(getRoomBookingOption('notificationEmails')) if getRoomBookingOption('notificationEmailsToBookedFor'): recipients.update(getEmailList(resv.contactEmail)) if resv.room.resvNotificationToResponsible: recipients.add(resv.room.getResponsible().getEmail()) maildata = { 'fromAddr': Config.getInstance().getNoReplyEmail(), 'toList': list(recipients), 'subject': subject.format(**msgArgs), 'body': msg.format(**msgArgs) } GenericMailer.send(GenericNotification(maildata))
if isinstance(self.getOwnerObject(), Avatar): try: notification = notifications.VidyoOwnerChosenNotification(self) GenericMailer.sendAndLog(notification, self.getConference(), self.getPlugin().getName()) except Exception, e: Logger.get('Vidyo').error( """Could not send VidyoOwnerChosenNotification for booking with id %s of event with id %s, exception: %s""" % (self.getId(), self.getConference().getId(), str(e))) #notification to admin if too many rooms in index if VidyoTools.needToSendCleaningReminder(): try: notification = notifications.VidyoCleaningNotification(self) GenericMailer.send(notification) except Exception, e: Logger.get('Vidyo').error( """Could not send VidyoCleaningNotification for booking with id %s of event with id %s, exception: %s""" % (self.getId(), self.getConference().getId(), str(e))) elif operation == 'modify': #notification to admin try: notification = notifications.VidyoPublicRoomModifiedNotificationAdmin(self) GenericMailer.sendAndLog(notification, self.getConference(), self.getPlugin().getName()) except Exception, e: Logger.get('Vidyo').error( """Could not send VidyoPublicRoomModifiedNotificationAdmin for booking with id %s of event with id %s, exception: %s""" %
GenericMailer.sendAndLog( notification, self.getConference(), "MaKaC/plugins/Collaboration/Vidyo/collaboration.py", self.getConference().getCreator()) except Exception, e: Logger.get('Vidyo').error( """Could not send VidyoOwnerChosenNotification for booking with id %s of event with id %s, exception: %s""" % (self.getId(), self.getConference().getId(), str(e))) #notification to admin if too many rooms in index if VidyoTools.needToSendCleaningReminder(): try: notification = notifications.VidyoCleaningNotification( self) GenericMailer.send(notification) except Exception, e: Logger.get('Vidyo').error( """Could not send VidyoCleaningNotification for booking with id %s of event with id %s, exception: %s""" % (self.getId(), self.getConference().getId(), str(e))) elif operation == 'modify': #notification to admin try: notification = notifications.VidyoPublicRoomModifiedNotificationAdmin( self) GenericMailer.sendAndLog( notification, self.getConference(), "MaKaC/plugins/Collaboration/Vidyo/collaboration.py", self.getConference().getCreator()) except Exception, e:
def send( self ): text = _("""Dear user, Your account has been disabled by the site administrator. """) maildata = { "fromAddr": "Indico Mailer<%s>"%Config.getInstance().getNoReplyEmail(), "toList": [self._user.getEmail()], "subject": _("[%s] Account disabled")%getSubjectIndicoTitle(), "body": text } GenericMailer.send(GenericNotification(maildata))
def send_login_info(user, event=None): token_storage = GenericCache('resetpass') endpoint = 'event.confLogin-resetPassword' if event else 'user.signIn-resetPassword' idList = user.getIdentityList() logins = [] for id in idList: if not hasattr(id, 'setPassword'): config = Config.getInstance() extra_message = config.getAuthenticatorConfigById( id.getAuthenticatorTag()).get("ResetPasswordMessage") msg = _( "Sorry, you are using an externally managed account (%s) to login into Indico." ) % id.getLogin() if extra_message: msg += "\n" + extra_message logins.append({ 'tag': id.getAuthenticatorTag(), 'login': id.getLogin(), 'error': msg }) else: tag = id.getAuthenticatorTag() login = id.getLogin() data = {'tag': tag, 'login': login} token = str(uuid.uuid4()) while token_storage.get(token): token = str(uuid.uuid4()) token_storage.set(token, data, 6 * 3600) url = url_for(endpoint, event, token=token, _external=True, _secure=True) logins.append({'tag': tag, 'login': login, 'link': url}) if not logins: url = urlHandlers.UHUserDetails.getURL(user) text = _( "Sorry, we did not find your login.\nPlease, create one here:\n%s" ) % url else: text = _( "You can use the following links within the next six hours to reset your password." ) for entry in logins: text += "\n\n==================\n" if 'link' in entry: text += _( "Click below to reset your password for the %s login '%s':\n" ) % (entry['tag'], entry['login']) text += entry['link'] else: text += entry['error'] text += "\n==================\n" maildata = { "fromAddr": "Indico Mailer <%s>" % Config.getInstance().getNoReplyEmail(), "toList": [user.getEmail()], "subject": _("[%s] Login Information") % getSubjectIndicoTitle(), "body": text } GenericMailer.send(GenericNotification(maildata))
def _process(self): canManageRegistration = self._conf.canManageRegistration( self._getUser()) if not canManageRegistration and not self._regForm.isActivated(): p = registrationForm.WPRegFormInactive(self, self._conf) return p.display() params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams( params, 'email') if email is None: raise FormValuesError( _("An email address has to be set in order to make the registration in the event." )) elif not validMail(email, False): raise FormValuesError(_("The given email address is not valid.")) matchedUsers = AvatarHolder().match({"email": email}, exact=1) if matchedUsers: user = matchedUsers[0] else: user = None # Check if the user can register if not canManageRegistration: # normal user registering. Managers can. if self._conf.getRegistrationForm().isFull(): self._redirect( urlHandlers.UHConfRegistrationFormDisplay.getURL( self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): p = registrationForm.WPRegistrationFormClosed(self, self._conf) return p.display() if user is None: if self._conf.hasRegistrantByEmail(email): raise FormValuesError( "There is already a user with the email \"%s\". Please choose another one" % email) else: if user.isRegisteredInConf( self._conf) or self._conf.hasRegistrantByEmail(email): if canManageRegistration: raise FormValuesError( "There is already a user with the email \"%s\". Please choose another one" % email) else: raise FormValuesError( "You have already registered with the email address \"%s\". If you need to modify your registration, please contact the managers of the conference." % email) rp = registration.Registrant() self._conf.addRegistrant(rp, user) rp.setValues(self._getRequestParams(), user) if user is not None: user.addRegistrant(rp) rp.setAvatar(user) # This creates the email to the new registrant and SENDS the email to the organizers if necessary... WTF. email = self._regForm.getNotification().createEmailNewRegistrant( self._regForm, rp) if self._regForm.isSendRegEmail() and rp.getEmail().strip(): modEticket = self._conf.getRegistrationForm().getETicket() if modEticket.isEnabled() and modEticket.isAttachedToEmail(): attachment = { 'name': "{0}-Ticket.pdf".format(self._target.getTitle()), 'binary': TicketToPDF(self._target, rp).getPDFBin(), } email["attachments"] = [attachment] GenericMailer.send(email) if canManageRegistration and user != self._getUser(): self._redirect(RHRegistrantListModif._uh.getURL(self._conf)) else: self._redirect( urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp))
def wrapper(*args, **kwargs): mails = fn(*args, **kwargs) if not isinstance(mails, list): mails = [mails] for mail in mails: GenericMailer.send(GenericNotification(mail))