fix the envolope sender to be valid by default
modified: app.py
This commit is contained in:
parent
68e7d6091a
commit
f05ad36b5d
1 changed files with 14 additions and 12 deletions
30
app.py
30
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"
|
return f"https://www.gravatar.com/avatar/{hash_code}?s={size}&d=identicon"
|
||||||
|
|
||||||
|
|
||||||
def send_email(to_email, subject, body):
|
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"] = from_email
|
||||||
|
msg["To"] = to_email
|
||||||
|
try:
|
||||||
|
s = smtplib.SMTP(smtp_host, smtp_port)
|
||||||
|
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("======= Email Sent =======")
|
||||||
log.info(f"To: {to_email}")
|
log.info(f"To: {to_email}")
|
||||||
log.info(f"Subject: {subject}")
|
log.info(f"Subject: {subject}")
|
||||||
log.info(f"Body:\n{body}")
|
log.info(f"Body:\n{body}")
|
||||||
log.info("==========================")
|
log.info("==========================")
|
||||||
|
|
||||||
msg = MIMEText(body)
|
|
||||||
msg["Subject"] = subject
|
|
||||||
msg["From"] = "noreply@example.com"
|
|
||||||
msg["To"] = to_email
|
|
||||||
|
|
||||||
try:
|
|
||||||
s = smtplib.SMTP(smtp_host, smtp_port)
|
|
||||||
s.sendmail("noreply@example.com", [to_email], msg.as_string())
|
|
||||||
s.quit()
|
|
||||||
except Exception as e:
|
|
||||||
log.error(f"Error sending email: {e}")
|
log.error(f"Error sending email: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1430,8 +1431,8 @@ def main(*config, **settings):
|
||||||
config.include("pyramid_tm")
|
config.include("pyramid_tm")
|
||||||
|
|
||||||
config.include("pyramid_openapi3")
|
config.include("pyramid_openapi3")
|
||||||
config.pyramid_openapi3_spec('openapi.yaml', route='/openapi.yaml')
|
config.pyramid_openapi3_spec("openapi.yaml", route="/openapi.yaml")
|
||||||
config.pyramid_openapi3_add_explorer(route='/docs')
|
config.pyramid_openapi3_add_explorer(route="/docs")
|
||||||
|
|
||||||
# Add .html.j2 extension for Jinja2 templates
|
# Add .html.j2 extension for Jinja2 templates
|
||||||
config.include("pyramid_jinja2")
|
config.include("pyramid_jinja2")
|
||||||
|
|
@ -1520,6 +1521,7 @@ def main(*config, **settings):
|
||||||
config.scan()
|
config.scan()
|
||||||
return config.make_wsgi_app()
|
return config.make_wsgi_app()
|
||||||
|
|
||||||
|
|
||||||
# Expose the WSGI application callable for uwsgi
|
# Expose the WSGI application callable for uwsgi
|
||||||
uwsgi_app = main({})
|
uwsgi_app = main({})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue