diff --git a/config/galaxy.ini.sample b/config/galaxy.ini.sample index e9176ff4292..643cb664248 100644 --- a/config/galaxy.ini.sample +++ b/config/galaxy.ini.sample @@ -360,10 +360,12 @@ paste.app_factory = galaxy.web.buildapp:app_factory # misconfiguration and other events user may encounter. #error_email_to = None -# Activation email is used as a sender ('from' field) for the account -# activation mail. We recommend using string in the following format: +# Email address to use in the 'From' field when sending emails for +# account activations, workflow step notifications and password resets. +# We recommend using string in the following format: # Galaxy Project -#activation_email = None +# If not configured, '' will be used. +#email_from = None # URL of the support resource for the galaxy instance. Used in activation # emails. diff --git a/lib/galaxy/config.py b/lib/galaxy/config.py index da313d80b2c..92161fa2937 100644 --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -184,7 +184,9 @@ class Configuration( object ): self.admin_users_list = [u.strip() for u in self.admin_users.split(',') if u] self.mailing_join_addr = kwargs.get('mailing_join_addr', 'galaxy-announce-join@bx.psu.edu') self.error_email_to = kwargs.get( 'error_email_to', None ) - self.activation_email = kwargs.get( 'activation_email', None ) + # activation_email was used until release_15.03 + activation_email = kwargs.get( 'activation_email', None ) + self.email_from = kwargs.get( 'email_from', activation_email ) self.user_activation_on = string_as_bool( kwargs.get( 'user_activation_on', False ) ) self.activation_grace_period = kwargs.get( 'activation_grace_period', None ) self.inactivity_box_content = kwargs.get( 'inactivity_box_content', None ) diff --git a/lib/galaxy/jobs/actions/post.py b/lib/galaxy/jobs/actions/post.py index dc7e0abd1e1..eff28baf095 100644 --- a/lib/galaxy/jobs/actions/post.py +++ b/lib/galaxy/jobs/actions/post.py @@ -5,6 +5,7 @@ immediate_actions listed below. Currently only used in workflows. import datetime import logging +import socket from galaxy.util import send_mail from galaxy.util.json import dumps @@ -63,11 +64,13 @@ class EmailAction(DefaultJobAction): @classmethod def execute(cls, app, sa_session, action, job, replacement_dict): - if action.action_arguments and 'host' in action.action_arguments: - host = action.action_arguments['host'] - else: - host = 'usegalaxy.org' - frm = 'galaxy-noreply@%s' % host + frm = app.config.email_from + if frm is None: + if action.action_arguments and 'host' in action.action_arguments: + host = action.action_arguments['host'] + else: + host = socket.getfqdn() + frm = 'galaxy-no-reply@%s' % host to = job.user.email subject = "Galaxy workflow step notification '%s'" % (job.history.name) outdata = ', '.join(ds.dataset.display_name() for ds in job.output_datasets) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 821d4ee297e..bb40305171c 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -3647,9 +3647,6 @@ class Request( object, Dictifiable ): comments = '' # Send email if trans.app.config.smtp_server is not None and self.notification and self.notification[ 'email' ]: - host = trans.request.host.split( ':' )[0] - if host in [ 'localhost', '127.0.0.1', '0.0.0.0' ]: - host = socket.getfqdn() body = """ Galaxy Sample Tracking Notification =================================== @@ -3686,7 +3683,12 @@ All samples in state: %(sample_state)s txt = txt + "%s -> %s/%s\r\n" % ( s.name, library_name, folder_name ) body = body + txt to = self.notification['email'] - frm = 'galaxy-no-reply@' + host + frm = trans.app.config.email_from + if frm is None: + host = trans.request.host.split( ':' )[0] + if host in [ 'localhost', '127.0.0.1', '0.0.0.0' ]: + host = socket.getfqdn() + frm = 'galaxy-no-reply@' + host subject = "Galaxy Sample Tracking notification: '%s' sequencing request" % self.name try: send_mail( frm, to, subject, body, trans.app.config ) diff --git a/lib/galaxy/webapps/galaxy/controllers/user.py b/lib/galaxy/webapps/galaxy/controllers/user.py index dd74d4fc9a0..38813d8b07a 100644 --- a/lib/galaxy/webapps/galaxy/controllers/user.py +++ b/lib/galaxy/webapps/galaxy/controllers/user.py @@ -835,7 +835,7 @@ class User( BaseUIController, UsesFormDefinitionsMixin, CreatesUsersMixin, Creat trans.app.config.error_email_to, trans.app.config.instance_resource_url)) to = email - frm = trans.app.config.activation_email + frm = trans.app.config.email_from subject = 'Galaxy Account Activation' try: util.send_mail( frm, to, subject, body, trans.app.config ) @@ -1180,13 +1180,15 @@ class User( BaseUIController, UsesFormDefinitionsMixin, CreatesUsersMixin, Creat trans.sa_session.add( prt ) trans.sa_session.flush() host = trans.request.host.split( ':' )[ 0 ] - if host == 'localhost': + if host in [ 'localhost', '127.0.0.1', '0.0.0.0' ]: host = socket.getfqdn() reset_url = url_for( controller='user', action="change_password", token=prt.token, qualified=True) body = PASSWORD_RESET_TEMPLATE % ( host, reset_url, reset_url ) - frm = 'galaxy-no-reply@' + host + frm = trans.app.config.email_from + if frm is None: + frm = 'galaxy-no-reply@' + host subject = 'Galaxy Password Reset' try: util.send_mail( frm, email, subject, body, trans.app.config ) diff --git a/lib/tool_shed/util/shed_util_common.py b/lib/tool_shed/util/shed_util_common.py index bf0477995ed..775a2e193e9 100644 --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -973,7 +973,7 @@ def handle_email_alerts( app, host, repository, content_alert_str='', new_repo_a # Send email alert to users that want them. if app.config.email_from is not None: email_from = app.config.email_from - elif host.split( ':' )[0] == 'localhost': + elif host.split( ':' )[0] in [ 'localhost', '127.0.0.1', '0.0.0.0' ]: email_from = 'galaxy-no-reply@' + socket.getfqdn() else: email_from = 'galaxy-no-reply@' + host.split( ':' )[0] diff --git a/scripts/cleanup_datasets/admin_cleanup_datasets.py b/scripts/cleanup_datasets/admin_cleanup_datasets.py index 083c4c85cb5..987f064b209 100644 --- a/scripts/cleanup_datasets/admin_cleanup_datasets.py +++ b/scripts/cleanup_datasets/admin_cleanup_datasets.py @@ -26,7 +26,7 @@ Optional Arguments: --smtp - Specify smtp server If not specified, use smtp settings specified in config file --fromaddr - Specify from address - If not specified, use error_email_to specified in config file + If not specified, use email_from specified in config file Email Template Variables: cutoff - the cutoff in days @@ -115,11 +115,11 @@ def main(): "or in the config file (smtp_server)") if options.fromaddr is not None: - config_dict['error_email_to'] = options.fromaddr - if config_dict.get('error_email_to') is None: + config_dict['email_from'] = options.fromaddr + if config_dict.get('email_from') is None: parser.error("From address must be specified as an option " "(--fromaddr) or in the config file " - "(error_email_to)") + "(email_from)") scriptdir = os.path.dirname(os.path.abspath(__file__)) template_file = options.template @@ -237,7 +237,7 @@ def administrative_delete_datasets(app, cutoff_time, cutoff_days, cutoff=cutoff_days) subject = "Galaxy Server Cleanup " \ "- %d datasets DELETED" % len(dataset_list) - fromaddr = config.error_email_to + fromaddr = config.email_from print "" print "From: %s" % fromaddr print "To: %s" % email