Merge pull request #23 from nsoranzo/dev

Uniform configuration of "From" field of sent emails.
This commit is contained in:
Dannon Baker
2015-03-13 11:02:37 -04:00
7 changed files with 33 additions and 22 deletions
+5 -3
View File
@@ -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 <galaxy-no-reply@example.com>
#activation_email = None
# If not configured, '<galaxy-no-reply@HOSTNAME>' will be used.
#email_from = None
# URL of the support resource for the galaxy instance. Used in activation
# emails.
+3 -1
View File
@@ -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 )
+8 -5
View File
@@ -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)
+6 -4
View File
@@ -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 )
@@ -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 )
+1 -1
View File
@@ -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]
@@ -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