From f05ad36b5da175f2207441993a95450ec7cedd66 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Wed, 22 Jan 2025 18:20:09 -0500 Subject: [PATCH] fix the envolope sender to be valid by default modified: app.py --- app.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app.py b/app.py index b0881bd..7c8b026 100644 --- a/app.py +++ b/app.py @@ -146,23 +146,24 @@ def get_gravatar_url(email, size=100): return f"https://www.gravatar.com/avatar/{hash_code}?s={size}&d=identicon" -def send_email(to_email, subject, body): - log.info("======= Email Sent =======") - log.info(f"To: {to_email}") - log.info(f"Subject: {subject}") - log.info(f"Body:\n{body}") - log.info("==========================") - +def send_email(to_email, subject, body, from_email=None): + if from_email is None: + from_email = os.environ.get("PYRAFILES_FROM_EMAIL", "master@master.unturf.com") msg = MIMEText(body) msg["Subject"] = subject - msg["From"] = "noreply@example.com" + msg["From"] = from_email msg["To"] = to_email - try: s = smtplib.SMTP(smtp_host, smtp_port) - s.sendmail("noreply@example.com", [to_email], msg.as_string()) + s.sendmail(from_email, [to_email], msg.as_string()) s.quit() except Exception as e: + log = logging.getLogger(__name__) + log.info("======= Email Sent =======") + log.info(f"To: {to_email}") + log.info(f"Subject: {subject}") + log.info(f"Body:\n{body}") + log.info("==========================") log.error(f"Error sending email: {e}") @@ -1430,8 +1431,8 @@ def main(*config, **settings): config.include("pyramid_tm") config.include("pyramid_openapi3") - config.pyramid_openapi3_spec('openapi.yaml', route='/openapi.yaml') - config.pyramid_openapi3_add_explorer(route='/docs') + config.pyramid_openapi3_spec("openapi.yaml", route="/openapi.yaml") + config.pyramid_openapi3_add_explorer(route="/docs") # Add .html.j2 extension for Jinja2 templates config.include("pyramid_jinja2") @@ -1520,6 +1521,7 @@ def main(*config, **settings): config.scan() return config.make_wsgi_app() + # Expose the WSGI application callable for uwsgi uwsgi_app = main({})