Skip to content

Commit

Permalink
Potential work-arounds for email problems (#80)
Browse files Browse the repository at this point in the history
* Modifications to get around issues sending notifications via gmail- added second address and changed format of message

* PEP8 line length fix
  • Loading branch information
archaeogeek authored and tomkralidis committed Jan 24, 2017
1 parent 704f9da commit 6d038f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions GeoHealthCheck/config_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
DEBUG = False
SQLALCHEMY_ECHO = False
SQLALCHEMY_DATABASE_URI = 'sqlite:///data.db'
# Alternative configuration for PostgreSQL database
# SQLALCHEMY_DATABASE_URI = 'postgresql://user:password@host:port/database'

# Replace None with 'your secret key string' in quotes
SECRET_KEY = None
Expand All @@ -41,6 +43,7 @@
GHC_NOTIFICATIONS_VERBOSITY = True
GHC_WWW_LINK_EXCEPTION_CHECK = False
GHC_ADMIN_EMAIL = 'you@example.com'
GHC_NOTIFICATIONS_EMAIL = 'you2@example.com'
GHC_SITE_TITLE = 'GeoHealthCheck Demonstration'
GHC_SITE_URL = 'http://host'

Expand Down
9 changes: 7 additions & 2 deletions GeoHealthCheck/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ def notify(config, resource, run, last_run_success):
'run': run
}

msg = render_template2('notification_email.txt', template_vars)
msgbody = render_template2('notification_email.txt', template_vars)

fromaddr = '%s <%s>' % (config['GHC_SITE_TITLE'],
config['GHC_ADMIN_EMAIL'])
toaddrs = config['GHC_ADMIN_EMAIL']
toaddrs = config['GHC_NOTIFICATIONS_EMAIL']

msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" %
(config['GHC_ADMIN_EMAIL'], toaddrs, config['GHC_SITE_TITLE']))

msg = msg + msgbody
print msg
server = smtplib.SMTP('%s:%s' % (config['GHC_SMTP']['server'],
config['GHC_SMTP']['port']))

Expand Down
2 changes: 1 addition & 1 deletion GeoHealthCheck/templates/notification_email.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ _('Subject') }}: [{{ config.GHC_SITE_TITLE }}] {{ result }}: {{ resource.title }}
{{ result }}: {{ resource.title }}


{{ _('Hi: this is an automated message from the') }} {{ config.GHC_SITE_TITLE }} {{ _('service') }}.
Expand Down

0 comments on commit 6d038f6

Please sign in to comment.