Ejemplo n.º 1
0
def sendmail(addr, text):
    if get_config('mg_api_key') and app.config['ADMINS']:
        ctf_name = get_config('ctf_name')
        mg_api_key = get_config('mg_api_key')
        return requests.post("https://api.mailgun.net/v2/mail" +
                             app.config['HOST'] + "/messages",
                             auth=("api", mg_api_key),
                             data={
                                 "from":
                                 "{} Admin <{}>".format(
                                     ctf_name, app.config['ADMINS'][0]),
                                 "to": [addr],
                                 "subject":
                                 "Message from {0}".format(ctf_name),
                                 "text":
                                 text
                             })
    elif app.config['MAIL_SERVER'] and app.config['MAIL_PORT'] and app.config[
            'ADMINS']:
        try:
            msg = Message("Message from {0}".format(get_config('ctf_name')),
                          sender=app.config['ADMINS'][0],
                          recipients=[addr])
            msg.body = text
            mail.send(msg)
            return True
        except:
            return False
    else:
        return False
Ejemplo n.º 2
0
def sendmail(addr, text):
    try:
        msg = Message("Message from {0}".format(app.config['CTF_NAME']), sender = app.config['ADMINS'][0], recipients = [addr])
        msg.body = text
        mail.send(msg)
        return True
    except:
        return False
Ejemplo n.º 3
0
Archivo: utils.py Proyecto: anhilo/CTFd
def sendmail(addr, text):
    if get_config('mg_api_key') and app.config['ADMINS']:
        ctf_name = get_config('ctf_name')
        mg_api_key = get_config('mg_api_key')
        return requests.post(
            "https://api.mailgun.net/v2/mail"+app.config['HOST']+"/messages",
            auth=("api", mg_api_key),
            data={"from": "{} Admin <{}>".format(ctf_name, app.config['ADMINS'][0]),
                  "to": [addr],
                  "subject": "Message from {0}".format(ctf_name),
                  "text": text})
    elif app.config['MAIL_SERVER'] and app.config['MAIL_PORT'] and app.config['ADMINS']:
        try:
            msg = Message("Message from {0}".format(get_config('ctf_name')), sender=app.config['ADMINS'][0], recipients=[addr])
            msg.body = text
            mail.send(msg)
            return True
        except:
            return False
    else:
        return False