Fixed mail sending

This commit is contained in:
Thastertyn 2024-03-14 22:13:52 +01:00
parent c310586fca
commit 7342516ce7
3 changed files with 8 additions and 10 deletions

View File

@ -6,8 +6,11 @@ from flasgger import Swagger
from app.doc.main_swag import main_swagger
app = Flask(__name__)
jwt_manager = JWTManager(app)
from app.config import FlaskTesting, FlaskProduction
app.config.from_object(FlaskTesting)
mail = Mail(app)
jwt_manager = JWTManager(app)
swag = Swagger(app, template=main_swagger)
def create_app():
@ -18,9 +21,6 @@ def create_app():
app.register_blueprint(bp_user)
app.register_blueprint(bp_cart)
from app.config import FlaskTesting, FlaskProduction
app.config.from_object(FlaskTesting)
from . import jwt_utils
return app

View File

@ -22,7 +22,8 @@ class FlaskTesting:
SERVER_NAME = os.environ.get('HOST') + ':' + os.environ.get('PORT')
MAIL_SERVER = os.environ.get('MAIL_SERVER')
MAIL_PORT = os.environ.get('MAIL_USERNAME')
MAIL_PORT = os.environ.get('MAIL_PORT')
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS')
MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER')

View File

@ -62,10 +62,7 @@ class UserService:
print(f"Error: {e}")
return {"Failed": "Failed to insert into database. Username or email are likely in use already"}, 500
# TODO Implement mail sending
# Currently throws error - connection refused
# send_mail("Successfully registered!", email, "Congratulations! Your account has been successfully created.\nThis mail also serves as a test that the email address is correct")
send_mail("Successfully registered!", email, "Congratulations! Your account has been successfully created.\nThis mail also serves as a test that the email address is correct")
return {"Success": "User created successfully"}, 200