Commit e9a5fad4 authored by Grant, Josh's avatar Grant, Josh
Browse files

make smtp server and port configurable through environmental variables

parent 9ac31e4a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ def send_email(subject, text):
    """
    logger = create_logger()
    from_address = ce('EMAIL_SENDER')
    smtp_address = ce('SMTP_ADDRESS', 'smtp.ornl.gov')
    smtp_port = ce('SMTP_PORT', 25)
    if from_address is None:
        logger.critical('Unable to send email as no EMAIL_SENDER set')
        return None
@@ -36,7 +38,7 @@ def send_email(subject, text):
    msg.attach(MIMEText(text, 'plain'))
    logger.info(f'Sending email to {to_address} from {from_address}')
    try:
        with smtplib.SMTP('smtp.ornl.gov', 25) as server:
        with smtplib.SMTP(smtp_address, smtp_port) as server:
            server.set_debuglevel(ce('EMAIL_DEBUG_LEVEL', 0))
            server.send_message(msg)
            server.quit()