Пример #1
0
 def feedback(self):
     try:
         vars = self.request.json_body
         sanitized_description = bleach.clean(vars['description'])
         html_body = u"<h3>L\'utilisateur <a href=\"mailto:{0}\">{0}</a> " \
             u"a remarqué le problème suivant:</h3><p>{1}</p>" \
             u"<p><a href=\"{3}\">Ouvrir le lien vers la carte</a></p>" \
             u"<h3>La couche suivante est concernée:</h3>" \
             u"<p>{2}</p>" \
             .format(vars['email'],
                     sanitized_description,
                     vars['layer'],
                     vars['url']
                     )
         support_email = self.config.get('feedback.support_email',
                                         '*****@*****.**')
         message = Message(author=vars['email'],
                           to=support_email,
                           subject=u'Un utilisateur a signalé un problème')
         message.plain = html_body
         message.rich = html_body
         message.encoding = 'utf-8'
         message.send()
     except Exception as e:
         log.exception(e)
         return HTTPNotFound()
     return {'success': True}
Пример #2
0
def send_email(sender, truename, emails, title, plain, rich):
    """
    notify using email
    sending alert email to followers
    """
    """
    rand send email 
    """
    day_str = datetime.datetime.strftime(datetime.datetime.today(),"%d%H")
    sender = 'Knowing <*****@*****.**>' % day_str
    
    logging.debug('Send email %s' % ', '.join((truename, str(emails), title, plain, rich)))

    try:
        mail = Message()
        mail.subject = title
        mail.sender = sender
        mail.to = u'%s <%s>' % (truename, emails[0])
        if len(emails) > 1:
            mail.cc = u','.join(emails[1:])
        mail.encoding = 'utf-8'
        mail.plain = plain
        mail.rich = rich
        mail.send()

    except Exception, e:
        logging.exception('Fail to send email.')
 def feedback(self):
     try:
         vars = self.request.json_body
         sanitized_description = bleach.clean(vars['description'])
         html_body = u"<h3>L\'utilisateur <a href=\"mailto:{0}\">{0}</a> " \
             u"a remarqué le problème suivant:</h3><p>{1}</p>" \
             u"<p><a href=\"{3}\">Ouvrir le lien vers la carte</a></p>" \
             u"<h3>La couche suivante est concernée:</h3>" \
             u"<p>{2}</p>" \
             .format(vars['email'],
                     sanitized_description,
                     vars['layer'],
                     vars['url']
                     )
         support_email = self.config.get('feedback.support_email',
                                         '*****@*****.**')
         message = Message(
             author=vars['email'],
             to=support_email,
             subject=u'Un utilisateur a signalé un problème')
         message.plain = html_body
         message.rich = html_body
         message.encoding = 'utf-8'
         message.send()
     except Exception as e:
         log.exception(e)
         return HTTPNotFound()
     return {'success': True}
Пример #4
0
def send_email(sender, truename, emails, title, plain, rich):
    """
    notify using email
    sending alert email to followers
    """
    """
    rand send email 
    """
    day_str = datetime.datetime.strftime(datetime.datetime.today(), "%d%H")
    sender = "Knowing <*****@*****.**>" % day_str

    logging.debug("Send email %s" % ", ".join((truename, str(emails), title, plain, rich)))

    try:
        mail = Message()
        mail.subject = title
        mail.sender = sender
        mail.to = u"%s <%s>" % (truename, emails[0])
        if len(emails) > 1:
            mail.cc = u",".join(emails[1:])
        mail.encoding = "utf-8"
        mail.plain = plain
        mail.rich = rich
        mail.send()

    except Exception, e:
        logging.exception("Fail to send email.")
Пример #5
0
    def send(self, mfrom, mto, subject, html_part):

        interface.start(self.turbomail_config)

        message = Message(mfrom, mto, subject=subject)
        #message.cc =('idea','*****@*****.**')
        message.encoding = 'gb2312'
        message.plain = "Mabotech"
        message.rich = html_part
        message.send()

        interface.stop()
Пример #6
0
def __notify(chart, message):
    """
    notify using email

    chart: Charts data row
    message: message body

    sending alert email to owner and followers
    """
    config = __get_config('webapp')

    mail_config = {}
    mail_config['mail.on'] = config['turbomail']['enable']
    mail_config['mail.manager'] = config['turbomail']['manager']
    mail_config['mail.transport'] = config['turbomail']['transport']
    mail_config['mail.smtp.server'] = config['turbomail']['server']

    sender = config['turbomail']['sender']
    """
    rand send email 
    """
    day_str = datetime.datetime.strftime(datetime.datetime.today(), "%d%H")
    sender = 'Knowing <*****@*****.**>' % day_str

    subject = message

    u = session.query(Users).filter(Users.username == chart.owner)

    addressee = ''
    if u:
        for i in u:
            if i.mobile:
                addressee = i.mobile + '@139.com'
            else:
                logger.warning("no mobile set for user \"%s\"" % i.username)
                return

    interface.start(mail_config)
    now = str(datetime.datetime.now())[0:19]

    chart_url = 'http://knowing.corp.anjuke.com/chart/%d' % chart.id

    html_part = u"<html><body><h1>Look, %s</h1><p>时间: %s</p><p>详细信息: %s</p><p><a href='%s'>%s</a></p><p>This mail is sent by Knowing</p></body></html>"
    html_part %= (chart.name, now, message, chart_url, chart_url)
    text_part = u"[critical] 时间: %s 详细信息: %s"
    text_part %= (now, message)

    mail = Message(sender, addressee, subject)
    mail.encoding = 'utf-8'
    mail.plain = message
    mail.rich = html_part
    flag = mail.send()
Пример #7
0
def __notify(chart, message):
    """
    notify using email

    chart: Charts data row
    message: message body

    sending alert email to owner and followers
    """
    config = __get_config('webapp')

    mail_config = {}
    mail_config['mail.on'] = config['turbomail']['enable']
    mail_config['mail.manager'] = config['turbomail']['manager']
    mail_config['mail.transport'] = config['turbomail']['transport']
    mail_config['mail.smtp.server'] = config['turbomail']['server']

    sender = config['turbomail']['sender']
    """
    rand send email 
    """
    day_str = datetime.datetime.strftime(datetime.datetime.today(),"%d%H")
    sender = 'Knowing <*****@*****.**>' % day_str

    subject = message

    u = session.query(Users).filter(Users.username == chart.owner)

    addressee = ''
    if u:
        for i in u:
            if i.mobile:
                addressee = i.mobile + '@139.com'
            else:
                logger.warning("no mobile set for user \"%s\"" % i.username)
                return

    interface.start(mail_config)
    now = str(datetime.datetime.now())[0:19]

    chart_url = 'http://knowing.corp.anjuke.com/chart/%d' % chart.id

    html_part = u"<html><body><h1>Look, %s</h1><p>时间: %s</p><p>详细信息: %s</p><p><a href='%s'>%s</a></p><p>This mail is sent by Knowing</p></body></html>"
    html_part %= (chart.name, now, message, chart_url, chart_url)
    text_part = u"[critical] 时间: %s 详细信息: %s"
    text_part %= (now, message)

    mail = Message(sender, addressee, subject)
    mail.encoding = 'utf-8'
    mail.plain = message
    mail.rich = html_part
    flag = mail.send()
Пример #8
0
    def send_email(self, imgs1, imgs2):
        day_str = datetime.datetime.strftime(datetime.datetime.today(),
                                             "%Y-%m-%d")
        mail = Message()
        mail.subject = u'#%s#SOS日报' % day_str
        mail.sender = '*****@*****.**'
        #mail.to = self.config['sos_receiver']
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        mailto = list(set(self.owner))
        mail.to = ','.join(mailto)

        mail.encoding = 'utf-8'
        mail.plain = u'本邮件由Knowing系统自动发送,如有疑问请联系运维团队,谢谢。'

        title_style = 'font-size: 15px; font-weight: bold; padding-top: 10px;'

        items = [
            u'<p>Hi All,</p><p>本邮件由Knowing系统自动发送,实时数据可<a href="http://knowing.corp.126.com/monitor/341">点此查看</a>,如有疑问请联系运维团队,谢谢。</p>'
        ]
        for img in imgs1:
            items.append(
                u'<div style="%s">%s</div><p><img src="cid:%d.png"></p>' %
                (title_style, img[1], img[0]))
            mail.embed(img[2], u'%d.png' % img[0])

        items.append(
            '<table border="0" cellspacing="0" cellpadding="0" width="1024">')
        for i in xrange(0, len(imgs2), 2):
            items.append(
                u'<tr><td><div style="%s">%s</div><img src="cid:%d.png"></td>'
                % (title_style, imgs2[i][1], imgs2[i][0]))
            mail.embed(imgs2[i][2], u'%d.png' % imgs2[i][0])
            if i + 1 < len(imgs2):
                items.append(
                    u'<td valign="bottom"><div style="%s">%s</div><img src="cid:%d.png"></td></tr>'
                    % (title_style, imgs2[i + 1][1], imgs2[i + 1][0]))
                mail.embed(imgs2[i + 1][2], u'%d.png' % imgs2[i + 1][0])
            else:
                items.append(u'<td>&nbsp;</td></tr>')
        items.append('</table>')
        mail.rich = u''.join(items)

        print 'Sending email...'
        mail.send()
Пример #9
0
    def send_email(self, imgs1, imgs2):
        day_str = datetime.datetime.strftime(datetime.datetime.today(),"%Y-%m-%d")
        mail = Message()
        mail.subject = u'#%s#SOS日报' % day_str
        mail.sender = '*****@*****.**'
        #mail.to = self.config['sos_receiver']
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        self.owner.append('*****@*****.**')
        mailto = list(set(self.owner))
        mail.to = ','.join(mailto)

        mail.encoding = 'utf-8'
        mail.plain = u'本邮件由Knowing系统自动发送,如有疑问请联系运维团队,谢谢。'

        title_style = 'font-size: 15px; font-weight: bold; padding-top: 10px;'

        items = [u'<p>Hi All,</p><p>本邮件由Knowing系统自动发送,实时数据可<a href="http://knowing.corp.126.com/monitor/341">点此查看</a>,如有疑问请联系运维团队,谢谢。</p>']
        for img in imgs1:
            items.append(u'<div style="%s">%s</div><p><img src="cid:%d.png"></p>' % (title_style, img[1], img[0]))
            mail.embed(img[2], u'%d.png' % img[0])

        items.append('<table border="0" cellspacing="0" cellpadding="0" width="1024">')
        for i in xrange(0, len(imgs2), 2):
            items.append(u'<tr><td><div style="%s">%s</div><img src="cid:%d.png"></td>' % (title_style, imgs2[i][1], imgs2[i][0]))
            mail.embed(imgs2[i][2], u'%d.png' % imgs2[i][0])
            if i + 1 < len(imgs2):
                items.append(u'<td valign="bottom"><div style="%s">%s</div><img src="cid:%d.png"></td></tr>' % (title_style, imgs2[i+1][1], imgs2[i+1][0]))
                mail.embed(imgs2[i+1][2], u'%d.png' % imgs2[i+1][0])
            else:
                items.append(u'<td>&nbsp;</td></tr>')
        items.append('</table>')
        mail.rich = u''.join(items)

        print 'Sending email...'
        mail.send()
Пример #10
0
    def comment(self):
        id = self.request.matchdict.get("map_id")
        map = Map.get(id)
        if map is None:
            return HTTPNotFound()

        # read the map author's email address from LDAP
        author = self.get_user_info(map.user_login)

        comment = self.request.params.get('comment')

        if self.request.params.get('name') and self.request.params.get('mail'):
            # feedback anonymous user
            feedback_name = self.request.params.get('name')
            feedback_mail = self.request.params.get('mail')
        else:
            # feedback loggedin user
            user = self.get_user_info(self.request.user.username)
            feedback_name = user[0]
            feedback_mail = user[1]
        try:
            message = Message(
                author='*****@*****.**',
                to=author[1],
                bcc='*****@*****.**',
                subject=(u'comment_email_subject')
                    % {'title': map.title +
                       " ( http://map.geoportail.lu/?map_id="+map.uuid+" ) ",
                       'feedback_name': feedback_name,
                       'feedback_mail': feedback_mail},
                plain=comment)
        except:
            traceback.print_exc(file=sys.stdout)
            return HTTPNotFound()
        message.encoding = 'utf-8'
        message.send()
        return {'success': True}
Пример #11
0
    def feedbackanf(self):
        try:
            vars = self.request.json_body
            map_id = self.config['anf']['map_id']
            map = self.request.db_mymaps.query(Map).get(map_id)
            if map is None:
                return HTTPNotFound()
            sanitized_description = bleach.clean(vars['description'])
            sanitized_lot = bleach.clean(vars['lot'])
            message = u"L\'utilisateur <a href=\"mailto:{0}\">{0}</a> " \
                u"a remarqué le problème suivant:<p>{1}</p> sur le lot" \
                u" {6}" \
                .format(vars['email'],
                        sanitized_description,
                        vars['layer'],
                        vars['url'],
                        vars['name'],
                        "http://map.geoportail.lu?map_id=" + map_id,
                        sanitized_lot,
                        )

            features = vars['features'].\
                replace(u'\ufffd', '?')
            feature_collection = geojson.\
                loads(features, object_hook=geojson.GeoJSON.to_instance)

            for feature in feature_collection['features']:
                obj = None
                try:
                    obj = Feature(feature)
                    obj.name = vars['name'] + " : " + sanitized_lot
                    obj.description = message
                except Exception as e:
                    log.exception(e)
                if obj is not None:
                    map.features.append(obj)
                self.request.db_mymaps.commit()

            html_body = u"<h3>L\'utilisateur <a href=\"mailto:{0}\">{4}</a> " \
                u"a remarqué le problème suivant:</h3><p>{1}</p>" \
                u" sur le lot {6}" \
                u"<p><a href=\"{3}\">Ouvrir le lien vers la carte</a></p>" \
                u"<p>L'incident a été enregistré dans cette <a href=\"{5}\">" \
                u"mymaps</a>:</p>" \
                .format(vars['email'],
                        sanitized_description,
                        vars['layer'],
                        vars['url'],
                        vars['name'],
                        "http://map.geoportail.lu?map_id=" + map_id,
                        sanitized_lot,
                        )

            support_email = self.config['anf']['email']
            message = Message(
                author=vars['email'],
                to=support_email,
                subject=u'Un utilisateur a signalé un problème')
            message.plain = html_body
            message.rich = html_body
            message.encoding = 'utf-8'
            message.send()
        except Exception as e:
            log.exception(e)
            return HTTPNotFound()
        return {'success': True}