Ejemplo n.º 1
0
    def __call__(self):
        portal = getToolByName(self.context, 'portal_url').getPortalObject()
        if 'error_submitted' in self.request.form:
            traceback = self.request.form.get('traceback', '')
            time = self.request.form.get('time', '')
            url = self.request.form.get('url', '')

            did = self.request.form.get('oc-did', '')
            expected = self.request.form.get('oc-expected', '')
            mto = portal.getProperty('email_from_address')
            email_sender = IEmailSender(portal)
            user = self.loggedinmember
            if not user:
                user_id = ''
            else:
                user_id = user.id  # works both for admin and remember members.
            user_email = self.request.form.get('oc-user-email', '').strip()
            if not user_email:
                domain = urlparse.urlparse(self.request.getURL())[1]
                if domain.startswith('www.'):
                    domain = domain[len('www.'):]
                user_email = "anonymous@%s" % domain

            msg = ('On %(time)s, %(user_id)s <%(user_email)s> went to the URL %(url)s.\n\n'
                   'Did: %(did)s\n\nExpected: %(expected)s\n\nTraceback: %(traceback)s' % locals())
            site = portal.getProperty('title', 'Untitled site')
            email_sender.sendMail(mto, msg, '[%s] site error report' % site,
                                  user_email)
            self.add_status_message(u'Thanks for your feedback.')
        return self.redirect(portal.absolute_url())
Ejemplo n.º 2
0
 def send(self, target=None, fields=None):
     sender = IEmailSender(self.portal)
     mto = self.viewed_member_info.get('email')
     mfrom = self.loggedinmember.getId()
     msg = self.request.form['message']
     subject = self.request.form['subject']
     sender.sendMail(mto, msg=msg, subject=subject, mfrom=mfrom)
     self.addPortalStatusMessage(_(u'psm_message_sent_to_user',
                                   u'Message sent.'))
     ret_url = self.request.form.get('ret_url') or self.context.absolute_url()
     return self.redirect(ret_url)
Ejemplo n.º 3
0
    def join(self, request_message=None):
        context = self.context
        joined = context.join()
        if not joined:
            return False

        sender = IEmailSender(self.portal)
        email_msg, email_subject = \
            self._construct_request_email(request_message)

        mto = context.get_admin_ids()
        for recipient in mto:
            try:
                sender.sendMail(recipient, 
                                msg=email_msg, subject=email_subject)
            except MailHostError:
                pass

        return True
Ejemplo n.º 4
0
 def _send_mail_to_pending_user(self, id, email, url):
     """ send a mail to a pending user """
     # TODO only send mail if in the pending workflow state
     mailhost_tool = self.get_tool("MailHost")
     site_url = getToolByName(self.context, 'portal_url')()
     message = _(u'email_to_pending_user',
                 mapping={u'user_name':id,
                          u'url':url,
                          u'portal_url': site_url,
                          u'portal_title':self.portal_title()})
     
     subject = _(u'email_to_pending_user_subject',
                 mapping={u'user_name':id,
                          u'url':url,
                          u'portal_url': site_url,
                          u'portal_title':self.portal_title()})
     
     sender = IEmailSender(self.portal)
     sender.sendMail(mto=email,
                     msg=message,
                     subject=subject)
Ejemplo n.º 5
0
    def _construct_request_email(self, request_message=None):
        team = self.context
        team_manage_url = self.team_manage_url
        member = self._loggedinmember
        member_string = member.getId()
        member_fn = member.getFullname()
        if member_fn:
            member_string = member_string + ' (' + member_fn + ')'
        email_msg = _(u'email_membership_requested',
                      mapping = {'member_id': member_string,
                                 'project_title': team.title,
                                 'project_noun': project_noun(),
                                 'team_manage_url': team_manage_url,
                                 }
                      )

        email_subject = _(u'email_membership_requested_subject',
                          mapping = {'member_id': member_string,
                                     'project_title': team.title,
                                     'project_noun': project_noun(),
                                     'team_manage_url': team_manage_url,
                                     }
                          )
        
        sender = IEmailSender(self.portal)
        email_msg = sender.constructMailMessage(email_msg)
        email_subject = sender.constructMailMessage(email_subject)

        if request_message:
            member_message = _(u'email_mship_request_message',
                               mapping = {'member_id': member_string,
                                          'project_title': team.title,
                                          'team_manage_url': team_manage_url,
                                          'member_message': detag(request_message),
                                          }
                               )
            member_message = sender.constructMailMessage(member_message)
            email_msg += member_message
        return (email_msg, email_subject)