コード例 #1
0
ファイル: user.py プロジェクト: giocalitri/adslabs
def send_email_to_user(title, message_html, recipients, sender=None):
    """ 
    Generic function to send an email to users
    """
    if not sender:
        sender = "*****@*****.**"
    msg = Message(title, html=message_html, sender=sender, recipients=recipients)
    mail.send(msg)  # @UndefinedVariable
コード例 #2
0
ファイル: views.py プロジェクト: romanchyla/adsabs
def send_feedback(form):
    """function that actually sends the email"""
    try:
        url_from = unquote_plus(form.page_url_hidden.data)
    except:
        url_from = ''
    message_body = "Sent from url: %s \n\nMessage:\n%s" % (url_from, form.feedback_text.data)
    msg = Message(u"ADSABS2 feedback from %s: %s" % (form.email.data, form.feedback_type.data),
                  body=message_body,
                  sender=form.email.data,
                  recipients=config.FEEDBACK_RECIPIENTS)
    mail.send(msg)
コード例 #3
0
ファイル: views.py プロジェクト: aaccomazzi/adsabs
def send_feedback(form):
    """function that actually sends the email"""
    
    anonymous = current_user is None or current_user.is_anonymous()
    user_id = "%s%s" % (getattr(g, 'user_cookie_id'), anonymous and " (anonymous)" or "")

    template_ctx = {
        'page_url': unquote_plus(form.page_url.data),
        'user_id': user_id,
        'feedback': form.feedback_text.data,
        # do a json round-trip to get pretty indenting
        'environ': json.dumps(json.loads(form.environ.data), indent=True),
        }
    message_body = render_template('message_body.txt', **template_ctx)
    msg = Message(u"ADSABS2 feedback from %s <%s>: %s" % (form.name.data, form.email.data, form.feedback_type.data),
                  body=message_body,
                  sender=form.email.data,
                  recipients=config.FEEDBACK_RECIPIENTS)

    mail.send(msg)
    statsd.incr("feedback.email.sent")