def new_user(slug, email):
    webhook_slugs = os.getenv("ZAPIER_ALERT_HOOKS", None)
    if (webhook_slugs is None) or is_test_email(email):
        return False

    for webhook_slug in webhook_slugs.split(","):

        zapier_webhook_url = "http://zapier.com/hooks/catch/n/{webhook_slug}/".format(
            webhook_slug=webhook_slug)
        data = {
            "user_profile_url": "https://impactstory.org/" + slug
        }
        headers = {'Content-type': 'application/json', 'Accept': 'application/json'}

        r = requests.post( zapier_webhook_url, data=data, headers=headers)
Exemplo n.º 2
0
def new_user(slug, email):
    webhook_slugs = os.getenv("ZAPIER_ALERT_HOOKS", None)
    if (webhook_slugs is None) or is_test_email(email):
        return False

    for webhook_slug in webhook_slugs.split(","):

        zapier_webhook_url = "http://zapier.com/hooks/catch/n/{webhook_slug}/".format(
            webhook_slug=webhook_slug)
        data = {"user_profile_url": "https://impactstory.org/" + slug}
        headers = {
            'Content-type': 'application/json',
            'Accept': 'application/json'
        }

        r = requests.post(zapier_webhook_url, data=data, headers=headers)
Exemplo n.º 3
0
def send(address, subject, template_name, context):

    if is_test_email(address):
        return False

    templateLoader = jinja2.FileSystemLoader(searchpath="totalimpactwebapp/templates")
    templateEnv = jinja2.Environment(loader=templateLoader)
    html_template = templateEnv.get_template(template_name + ".html")

    html_to_send = html_template.render(context)

    mailer = mandrill.Mandrill(os.getenv("MANDRILL_APIKEY"))

    addressee = {"email": address}
    try:
        addressee["name"] = context["name"]
    except KeyError:
        pass


    msg = {
        "html": html_to_send,
        "subject": subject,
        "from_email": "*****@*****.**",
        "from_name": "The Impactstory team",
        "to": [addressee],  # must be a list
        "track_opens": True,
        "track_clicks": True
    }

    try:
        msg["tags"] = context["tags"]
    except KeyError:
        pass

    mailer.messages.send(msg)
    logger.info(u"Sent an email to " + address)

    return msg
Exemplo n.º 4
0
def send(address, subject, template_name, context):

    if is_test_email(address):
        return False

    templateLoader = jinja2.FileSystemLoader(searchpath="totalimpactwebapp/templates")
    templateEnv = jinja2.Environment(loader=templateLoader)
    html_template = templateEnv.get_template(template_name + ".html")

    html_to_send = html_template.render(context)

    mailer = mandrill.Mandrill(os.getenv("MANDRILL_APIKEY"))

    adressee = {"email": address}
    try:
        adressee["name"] = context["name"]
    except KeyError:
        pass


    msg = {
        "html": html_to_send,
        "subject": subject,
        "from_email": "*****@*****.**",
        "from_name": "The Impactstory team",
        "to": [adressee],  # must be a list
        "track_opens": True,
        "track_clicks": True
    }

    try:
        msg["tags"] = context["tags"]
    except KeyError:
        pass

    mailer.messages.send(msg)
    logger.info(u"Sent an email to " + address)

    return msg
Exemplo n.º 5
0
def send_welcome_email(email, given_name):

    if is_test_email(email):
        return False


    # send the email here...
    mailer = mandrill.Mandrill(os.getenv("MANDRILL_APIKEY"))

    text = """Hi {given_name},\nWelcome to Impactstory!  You just joined thousands of other cutting-edge researchers who are discovering the full impact of their research.\n\n\
Got any questions? Drop us a line at [email protected] and we'll be glad to help.\n\n
Want inside tips and insights about open science and altmetrics, along with actionable content that helps maximize your research impact? Then you're going to absolutely love our free newsletter. Check it out here: http://eepurl.com/RaRZ1\n\n
As a non-profit, we're passionate about helping to build a more open, expansive, and web-native science. It's why we do this. And we're thrilled that you've chosen to be part of it.\n\n
All our best,\nHeather, Jason, and Stacy""".format(given_name=given_name)

    html = """<p>Hi {given_name},</p>
<p>Welcome to Impactstory!  You just joined thousands of other cutting-edge researchers who are discovering the full impact of their research.</p>
<p>Got any questions? Drop us a line at [email protected] and we'll be glad to help.</p>
<p>Want inside tips and insights about open science and altmetrics, along with actionable content that helps maximize your research impact? Then you're going to absolutely love our free newsletter: <a href='http://eepurl.com/RaRZ1'>click here to check it out.</a></p>
<p>As a non-profit, we're passionate about helping to build a more open, expansive, and web-native science. It's why we do this. And we're thrilled that you've chosen to be part of it.</p>
<p>All our best,<br>Heather, Jason, and Stacy</p>""".format(given_name=given_name)

    msg = {
        "text": text,
        "html": html,
        "subject": "Welcome to Impactstory!",
        "from_email": "*****@*****.**",
        "from_name": "The Impactstory team",
        "to": [{"email": email, "name": given_name}],  # must be a list
        "tags": ["password-resets"],
        "track_opens": False,
        "track_clicks": False
    }
    mailer.messages.send(msg)
    logger.info(u"Sent a welcome email to " + email)

    return True