From 2895799c716394b45dfddb10c7ecf304183f7e92 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 3 Oct 2021 22:30:43 +0200 Subject: [PATCH] gfdf --- files/__main__.py | 2 +- files/mail/__init__.py | 23 +++++------------------ files/routes/static.py | 9 --------- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index 1cbec07ce..6e34f486c 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -64,7 +64,7 @@ app.config["RATELIMIT_STORAGE_URL"] = environ.get("REDIS_URL", "redis://127.0.0. app.config['MAIL_SERVER'] = 'smtp.gmail.com' app.config['MAIL_PORT'] = 587 app.config['MAIL_USE_TLS'] = True -app.config['MAIL_USERNAME'] = 'Aevann3@gmail.com' +app.config['MAIL_USERNAME'] = environ.get("MAIL_USERNAME", "").strip() app.config['MAIL_PASSWORD'] = environ.get("MAIL_PASSWORD", "").strip() r=redis.Redis(host=environ.get("REDIS_URL", "redis://127.0.0.1"), decode_responses=True, ssl_cert_reqs=None) diff --git a/files/mail/__init__.py b/files/mail/__init__.py index 6ab92ed6a..dafbc05a7 100644 --- a/files/mail/__init__.py +++ b/files/mail/__init__.py @@ -7,30 +7,17 @@ from urllib.parse import quote from files.helpers.security import * from files.helpers.wrappers import * from files.classes import * -from files.__main__ import app +from files.__main__ import app, mail +from flask_mail import Message site = environ.get("DOMAIN").strip() name = environ.get("SITE_NAME").strip() -mailgun_domain = environ.get("MAILGUN_DOMAIN", "").strip() -def send_mail(to_address, subject, html, plaintext=None, files={}, - from_address=f"{name} "): - url = f"https://api.mailgun.net/v3/{mailgun_domain}/messages" +def send_mail(to_address, subject, html): - data = {"from": from_address, - "to": [to_address], - "subject": subject, - "text": plaintext, - "html": html, - } - - return requests.post(url, - auth=( - "api", environ.get("MAILGUN_KEY").strip()), - data=data, - files=[("attachment", (k, files[k])) for k in files] - ) + msg = Message(html=html, subject=subject, sender="rdrama@rdrama.net", recipients=[to_address]) + mail.send(msg) def send_verification_email(user, email=None): diff --git a/files/routes/static.py b/files/routes/static.py index ece4e2a75..2f2741162 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -6,19 +6,10 @@ from sqlalchemy import func from os import path import calendar import matplotlib.pyplot as plt -from flask_mail import Message site = environ.get("DOMAIN").strip() site_name = environ.get("SITE_NAME").strip() -@app.route("/mailtest") -def mailtest(): - msg = Message(html="

Hello

", - sender="rdrama@rdrama.net", - recipients=["randomname42029@gmail.com"]) - mail.send(msg) - return "sex" - @app.get('/rules') @auth_desired def static_rules(v):