Exemple #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())
Exemple #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)
    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
Exemple #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)