use mailgun again

master
Aevann1 2022-10-08 02:44:02 +02:00
parent aa8e7055fb
commit cfd4b6399f
9 changed files with 23 additions and 25 deletions

4
env
View File

@ -28,8 +28,8 @@ DISABLE_DOWNVOTES=0
DUES=0 DUES=0
DEFAULT_THEME=midnight DEFAULT_THEME=midnight
DEFAULT_COLOR=805ad5 DEFAULT_COLOR=805ad5
MAIL_USERNAME=blahblahblah@gmail.com EMAIL=blahblahblah@gmail.com
MAIL_PASSWORD=blahblahblah MAILGUN_KEY=blahblahblah
DESCRIPTION=rdrama.net caters to drama in all forms such as: Real life, videos, photos, gossip, rumors, news sites, Reddit, and Beyond™. There isn't drama we won't touch, and we want it all! DESCRIPTION=rdrama.net caters to drama in all forms such as: Real life, videos, photos, gossip, rumors, news sites, Reddit, and Beyond™. There isn't drama we won't touch, and we want it all!
CF_KEY=blahblahblah CF_KEY=blahblahblah
CF_ZONE=blahblahblah CF_ZONE=blahblahblah

View File

@ -6,7 +6,6 @@ from flask import *
from flask_caching import Cache from flask_caching import Cache
from flask_limiter import Limiter from flask_limiter import Limiter
from flask_compress import Compress from flask_compress import Compress
from flask_mail import Mail
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy import * from sqlalchemy import *
@ -41,16 +40,6 @@ app.config['SQLALCHEMY_DATABASE_URL'] = environ.get("DATABASE_URL", "postgresql:
app.config["CACHE_TYPE"] = "RedisCache" app.config["CACHE_TYPE"] = "RedisCache"
app.config["CACHE_REDIS_URL"] = environ.get("REDIS_URL", "redis://localhost") app.config["CACHE_REDIS_URL"] = environ.get("REDIS_URL", "redis://localhost")
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
if environ.get("MAIL_USERNAME2") and random.random() < 0.5:
app.config['MAIL_USERNAME'] = environ.get("MAIL_USERNAME2", "").strip()
app.config['MAIL_PASSWORD'] = environ.get("MAIL_PASSWORD2", "").strip()
else:
app.config['MAIL_USERNAME'] = environ.get("MAIL_USERNAME", "").strip()
app.config['MAIL_PASSWORD'] = environ.get("MAIL_PASSWORD", "").strip()
app.config['SETTINGS'] = {} app.config['SETTINGS'] = {}
@ -76,7 +65,6 @@ db_session = scoped_session(sessionmaker(bind=engine, autoflush=False))
cache = Cache(app) cache = Cache(app)
Compress(app) Compress(app)
mail = Mail(app)
if not path.isfile(f'/site_settings.json'): if not path.isfile(f'/site_settings.json'):
with open('/site_settings.json', 'w', encoding='utf_8') as f: with open('/site_settings.json', 'w', encoding='utf_8') as f:

View File

@ -38,8 +38,9 @@ CARD_VIEW = bool(int(environ.get("CARD_VIEW").strip()))
DISABLE_DOWNVOTES = bool(int(environ.get("DISABLE_DOWNVOTES").strip())) DISABLE_DOWNVOTES = bool(int(environ.get("DISABLE_DOWNVOTES").strip()))
DUES = int(environ.get("DUES").strip()) DUES = int(environ.get("DUES").strip())
DEFAULT_THEME = environ.get("DEFAULT_THEME").strip() DEFAULT_THEME = environ.get("DEFAULT_THEME").strip()
DEFAULT_COLOR = environ.get("DEFAULT_COLOR", "805ad5").strip() DEFAULT_COLOR = environ.get("DEFAULT_COLOR").strip()
MAIL_USERNAME = environ.get("MAIL_USERNAME").strip() EMAIL = environ.get("EMAIL").strip()
MAILGUN_KEY = environ.get("MAILGUN_KEY").strip()
DESCRIPTION = environ.get("DESCRIPTION").strip() DESCRIPTION = environ.get("DESCRIPTION").strip()
CF_KEY = environ.get("CF_KEY").strip() CF_KEY = environ.get("CF_KEY").strip()
CF_ZONE = environ.get("CF_ZONE").strip() CF_ZONE = environ.get("CF_ZONE").strip()

View File

@ -75,5 +75,5 @@ def inject_constants():
"KOFI_TOKEN":KOFI_TOKEN, "KOFI_LINK":KOFI_LINK, "KOFI_TOKEN":KOFI_TOKEN, "KOFI_LINK":KOFI_LINK,
"approved_embed_hosts":approved_embed_hosts, "approved_embed_hosts":approved_embed_hosts,
"site_settings":app.config['SETTINGS'], "site_settings":app.config['SETTINGS'],
"MAIL_USERNAME":app.config['MAIL_USERNAME'], "EMAIL":EMAIL,
} }

View File

@ -1,3 +1,4 @@
import requests
import time import time
from flask import * from flask import *
from urllib.parse import quote from urllib.parse import quote
@ -8,14 +9,23 @@ from files.helpers.const import *
from files.helpers.get import * from files.helpers.get import *
from files.helpers.actions import * from files.helpers.actions import *
from files.classes import * from files.classes import *
from files.__main__ import app, mail, limiter from files.__main__ import app, limiter
from flask_mail import Message
def send_mail(to_address, subject, html): def send_mail(to_address, subject, html):
if MAILGUN_KEY == 'blahblahblah': return
msg = Message(html=html, subject=subject, sender=app.config['MAIL_USERNAME'], recipients=[to_address]) url = f"https://api.mailgun.net/v3/{SITE}/messages"
mail.send(msg)
auth = ("api", MAILGUN_KEY)
data = {"from": EMAIL,
"to": [to_address],
"subject": subject,
"html": html,
}
requests.post(url, auth=auth, data=data)
def send_verification_email(user, email=None): def send_verification_email(user, email=None):

View File

@ -1,5 +1,5 @@
from files.mail import * from files.mail import *
from files.__main__ import app, limiter, mail from files.__main__ import app, limiter
from files.helpers.alerts import * from files.helpers.alerts import *
from files.helpers.const import * from files.helpers.const import *
from files.helpers.actions import * from files.helpers.actions import *

View File

@ -1,4 +1,4 @@
from files.__main__ import app, limiter, mail from files.__main__ import app, limiter
from files.helpers.alerts import * from files.helpers.alerts import *
from files.helpers.wrappers import * from files.helpers.wrappers import *
from files.helpers.get import * from files.helpers.get import *

View File

@ -53,6 +53,6 @@
{% include "emoji_modal.html" %} {% include "emoji_modal.html" %}
{% else %} {% else %}
<h4>by email: {{MAIL_USERNAME}}</h4> <h4>by email: {{EMAIL}}</h4>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -5,7 +5,6 @@ Flask
Flask-Caching Flask-Caching
Flask-Compress Flask-Compress
Flask-Limiter Flask-Limiter
Flask-Mail
Flask-Socketio Flask-Socketio
gevent gevent
gevent-websocket gevent-websocket