diff --git a/auto_rx/auto_rx.py b/auto_rx/auto_rx.py index 137a6b9..55517f1 100644 --- a/auto_rx/auto_rx.py +++ b/auto_rx/auto_rx.py @@ -486,7 +486,8 @@ def main(): _email_notification = EmailNotification( smtp_server = config['email_smtp_server'], mail_from = config['email_from'], - mail_to = config['email_to'] + mail_to = config['email_to'], + mail_subject = config['email_subject'] ) exporter_objects.append(_email_notification) diff --git a/auto_rx/autorx/config.py b/auto_rx/autorx/config.py index ed49e60..01a9af0 100644 --- a/auto_rx/autorx/config.py +++ b/auto_rx/autorx/config.py @@ -40,11 +40,12 @@ def read_auto_rx_config(filename): auto_rx_config = { # Log Settings 'per_sonde_log' : True, - # Email Settings - 'email_enabled': False, - 'email_smtp_server': 'localhost', - 'email_from': 'sonde@localhost', - 'email_to': None, + # Email Settings + 'email_enabled': False, + 'email_smtp_server': 'localhost', + 'email_from': 'sonde@localhost', + 'email_to': None, + 'email_subject': " Sonde launch detected on : ", # SDR Settings 'sdr_fm': 'rtl_fm', 'sdr_power': 'rtl_power', @@ -133,8 +134,9 @@ def read_auto_rx_config(filename): auto_rx_config['email_smtp_server'] = config.get('email', 'smtp_server') auto_rx_config['email_from'] = config.get('email', 'from') auto_rx_config['email_to'] = config.get('email', 'to') + auto_rx_config['email_subject'] = config.get('email', 'subject') except: - logging.error("Config - Invalid email settings. Disabling.") + logging.error("Config - Invalid or missing email settings. Disabling.") auto_rx_config['email_enabled'] = False # SDR Settings diff --git a/auto_rx/autorx/email_notification.py b/auto_rx/autorx/email_notification.py index 81bedff..387f579 100644 --- a/auto_rx/autorx/email_notification.py +++ b/auto_rx/autorx/email_notification.py @@ -32,11 +32,12 @@ class EmailNotification(object): # We require the following fields to be present in the input telemetry dict. REQUIRED_FIELDS = [ 'id', 'lat', 'lon', 'alt', 'type', 'freq'] - def __init__(self, smtp_server = 'localhost', mail_from = None, mail_to = None): + def __init__(self, smtp_server = 'localhost', mail_from = None, mail_to = None, mail_subject = None): """ Init a new E-Mail Notification Thread """ self.smtp_server = smtp_server self.mail_from = mail_from self.mail_to = mail_to + self.mail_subject = mail_subject # Dictionary to track sonde IDs self.sondes = {} @@ -103,7 +104,13 @@ class EmailNotification(object): msg += 'https://sondehub.org/%s\n' % _id msg = MIMEText(msg, 'plain', 'UTF-8') - msg['Subject'] = 'Sonde launch detected: ' + _id + + # Construct subject + msg['Subject'] = self.mail_subject + msg['Subject'].replace('', telemetry['id']) + msg['Subject'].replace('', telemetry['type']) + msg['Subject'].replace('', telemetry['freq']) + msg['From'] = self.mail_from msg['To'] = self.mail_to msg["Date"] = formatdate() diff --git a/auto_rx/station.cfg.example b/auto_rx/station.cfg.example index 1033447..00fcc0e 100644 --- a/auto_rx/station.cfg.example +++ b/auto_rx/station.cfg.example @@ -219,6 +219,11 @@ email_enabled = False smtp_server = localhost from = sonde@localhost to = someone@example.com +# Custom subject field. The following fields can be included: +# - Sonde Frequency, i.e. 401.520 MHz +# - Sonde Type (RS94/RS41) +# - Sonde Serial Number (i.e. M1234567) +subject = Sonde launch detected on :