Hi all, just in case anyone runs into the same problem, a short update with a solution. On 08/12/2011 01:59 PM, Enis Afgan wrote:
On Fri, Aug 12, 2011 at 4:37 AM, Holger Klein <h.klein@imb-mainz.de <mailto:h.klein@imb-mainz.de>> wrote:
Hi Dannon,
thanks for the info. I'd like to take this a small step further. I added the variable smtp_from to universe_wsgi.ini. Then I modified the util.send_mail in ./lib/galaxy/util/__init__.py to check if config.smtp_from is set:
if config.smtp_from is None: msg[ 'From' ] = frm else: msg[ 'From' ] = config.smtp_from
Still frm is set to the old value (galaxy-no-reply@computeserver). Can anyone point me to the place where universe_wsgi.ini is actually parsed and the config dictionary is filled?
The parsing of the config file is done as part of Python's paste and it's then made available to the rest of Galaxy via lib/galaxy/config.py. There is only one instance of that class for the entire app but the send_mail method you were looking at does not have access to that object. So, you should look higher up in the hierarchy and set frm in the method that calls send_mail (there seem to be several places where it's called).
The send_mail method gets "config" as the last argument, so the variables from universe_wsgi.ini are accessible within the function. I did the following: 1) modify universe_wsgi.ini: add the line smtp_from = desired_from@localhost.net 2) modify galaxy-dist/lib/galaxy/config.py: add the line self.smtp_from = kwargs.get( 'smtp_from', None ) 3) modify function send_mail in galaxy-dist/lib/galaxy/util/__init__.py: line 550: ## msg[ 'From' ] = frm if config.smtp_from is None: msg[ 'From' ] = frm smtp_frm = frm else: msg[ 'From' ] = config.smtp_from smtp_frm = config.smtp_from [...] ## end of function send_mail: ## s.sendmail( frm, to, msg.as_string() ) s.sendmail( smtp_frm, to, msg.as_string() ) Now galaxy checks if the variable smtp_from is set; if yes, it adjusts the from header in all cases the send_mail function is used, otherwise it uses the old method. I attach patches, feel free to add if you think this could be useful for anyone else but me. Cheers, Holger -- Dr. Holger Klein Core Facility Bioinformatics Institute of Molecular Biology gGmbH (IMB) http://www.imb-mainz.de/ Tel: +49(6131) 39 21511