Skip to content
Snippets Groups Projects
Commit b769ee48 authored by Vermaat's avatar Vermaat
Browse files

Customizable sender address in batch job notifications

This address is set with the new `BATCH_NOTIFICATION_EMAIL` config
setting and defaults to the value of `EMAIL`.
parent 846f6b02
No related branches found
No related tags found
No related merge requests found
...@@ -58,12 +58,17 @@ not set by default. ...@@ -58,12 +58,17 @@ not set by default.
.. _config-email: .. _config-email:
EMAIL EMAIL
The email address used in contact information on the website, as sender in The email address used in contact information on the website and sent with
batch job notifications, and in communication with the NCBI webservices NCBI Entrez calls.
using Entrez.
`Default value:` ``mutalyzer@humgen.nl`` `Default value:` ``mutalyzer@humgen.nl``
BATCH_NOTIFICATION_EMAIL
The email address used as sender in batch job notifications. If set to
`None`, the value of :ref:`EMAIL <config-email>` will be used.
`Default value:` `None`
.. _config-debug: .. _config-debug:
DEBUG DEBUG
......
...@@ -106,6 +106,7 @@ class Scheduler() : ...@@ -106,6 +106,7 @@ class Scheduler() :
#TODO: Handle Connection errors in a try, except clause #TODO: Handle Connection errors in a try, except clause
#Expected errors: socket.error #Expected errors: socket.error
from_address = settings.BATCH_NOTIFICATION_EMAIL or settings.EMAIL
download_url = website.url_for('batch_job_result', download_url = website.url_for('batch_job_result',
result_id=result_id) result_id=result_id)
...@@ -123,7 +124,7 @@ With kind regards, ...@@ -123,7 +124,7 @@ With kind regards,
Mutalyzer batch scheduler""" % download_url) Mutalyzer batch scheduler""" % download_url)
message["Subject"] = "Result of your Mutalyzer batch job" message["Subject"] = "Result of your Mutalyzer batch job"
message["From"] = settings.EMAIL message["From"] = from_address
message["To"] = mailTo message["To"] = mailTo
try: try:
...@@ -138,7 +139,7 @@ Mutalyzer batch scheduler""" % download_url) ...@@ -138,7 +139,7 @@ Mutalyzer batch scheduler""" % download_url)
return return
try: try:
smtpInstance.sendmail(settings.EMAIL, mailTo, message.as_string()) smtpInstance.sendmail(from_address, mailTo, message.as_string())
except smtplib.SMTPRecipientsRefused as e: except smtplib.SMTPRecipientsRefused as e:
for address, (code, error) in e.recipients.items(): for address, (code, error) in e.recipients.items():
print 'Could not send email to %s: (%s) %s' % (address, print 'Could not send email to %s: (%s) %s' % (address,
......
...@@ -13,11 +13,14 @@ DEBUG = False ...@@ -13,11 +13,14 @@ DEBUG = False
# We are running unit tests. # We are running unit tests.
TESTING = False TESTING = False
# This address is used in contact information on the website, as sender in # This email address is used in contact information on the website and sent
# batch job notifications, and with retrieval of records at the NCBI using # with NCBI Entrez calls.
# Entrez.
EMAIL = 'mutalyzer@humgen.nl' EMAIL = 'mutalyzer@humgen.nl'
# This email address is used as sender in batch job notifications. If `None`,
# the value of `EMAIL` will be used.
BATCH_NOTIFICATION_EMAIL = None
# The cache directory. Used to store uploaded and downloaded files (e.g., # The cache directory. Used to store uploaded and downloaded files (e.g.,
# reference files from NCBI or user) and batch job results. # reference files from NCBI or user) and batch job results.
CACHE_DIR = '/tmp' CACHE_DIR = '/tmp'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment