global configuration of email "from" possible?
Hi all, for the email functionality of our local galaxy instance I'm forced to use SMTP authentication and to use a specific "from", which is different to what galaxy generates automatically. Now galaxy generates a "from" like galaxy@computeserver.imb.uni-mainz.de but I want to set this to galaxy@imb-mainz.de. A quick check shows that the send_mail function defined in lib/galaxy/util/__init__.py is called in various places. Is there a way to set the "from" to a specific value? If not, it send_mail the only galaxy-function used to send mail? Cheers, Holger -- Dr. Holger Klein Core Facility Bioinformatics Institute of Molecular Biology gGmbH (IMB) http://www.imb-mainz.de/ Tel: +49(6131) 39 21511
Holger, There isn't currently a galaxy-wide configuration for the from header address. Most places use frm = 'galaxy-noreply@%s' % host, where host is the fqdn of the box, as you've seen. I took a quick look, and it does look like everything that sends mail uses util.send_mail, so you could just modify that method to ignore the input frm parameter and immediately set it to frm = 'galaxy@imb-mainz.de' and you should be good to go. -Dannon On Aug 3, 2011, at 4:52 AM, Holger Klein wrote:
Hi all,
for the email functionality of our local galaxy instance I'm forced to use SMTP authentication and to use a specific "from", which is different to what galaxy generates automatically.
Now galaxy generates a "from" like galaxy@computeserver.imb.uni-mainz.de but I want to set this to galaxy@imb-mainz.de.
A quick check shows that the send_mail function defined in lib/galaxy/util/__init__.py is called in various places.
Is there a way to set the "from" to a specific value?
If not, it send_mail the only galaxy-function used to send mail?
Cheers, Holger
-- Dr. Holger Klein Core Facility Bioinformatics Institute of Molecular Biology gGmbH (IMB) http://www.imb-mainz.de/ Tel: +49(6131) 39 21511 ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at:
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? Holger On 08/03/2011 02:53 PM, Dannon Baker wrote:
Holger,
There isn't currently a galaxy-wide configuration for the from header address. Most places use frm = 'galaxy-noreply@%s' % host, where host is the fqdn of the box, as you've seen. I took a quick look, and it does look like everything that sends mail uses util.send_mail, so you could just modify that method to ignore the input frm parameter and immediately set it to frm = 'galaxy@imb-mainz.de' and you should be good to go.
-Dannon
On Aug 3, 2011, at 4:52 AM, Holger Klein wrote:
Hi all,
for the email functionality of our local galaxy instance I'm forced to use SMTP authentication and to use a specific "from", which is different to what galaxy generates automatically.
Now galaxy generates a "from" like galaxy@computeserver.imb.uni-mainz.de but I want to set this to galaxy@imb-mainz.de.
A quick check shows that the send_mail function defined in lib/galaxy/util/__init__.py is called in various places.
Is there a way to set the "from" to a specific value?
If not, it send_mail the only galaxy-function used to send mail?
Cheers, Holger
-- Dr. Holger Klein Core Facility Bioinformatics Institute of Molecular Biology gGmbH (IMB) http://www.imb-mainz.de/ Tel: +49(6131) 39 21511 ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at:
-- Dr. Holger Klein Core Facility Bioinformatics Institute of Molecular Biology gGmbH (IMB) http://www.imb-mainz.de/ Tel: +49(6131) 39 21511
Hi Holger, On Fri, Aug 12, 2011 at 4:37 AM, Holger Klein <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). Good luck, Enis
Holger
Holger,
There isn't currently a galaxy-wide configuration for the from header address. Most places use frm = 'galaxy-noreply@%s' % host, where host is
On 08/03/2011 02:53 PM, Dannon Baker wrote: the fqdn of the box, as you've seen. I took a quick look, and it does look like everything that sends mail uses util.send_mail, so you could just modify that method to ignore the input frm parameter and immediately set it to frm = 'galaxy@imb-mainz.de' and you should be good to go.
-Dannon
On Aug 3, 2011, at 4:52 AM, Holger Klein wrote:
Hi all,
for the email functionality of our local galaxy instance I'm forced to use SMTP authentication and to use a specific "from", which is different to what galaxy generates automatically.
Now galaxy generates a "from" like galaxy@computeserver.imb.uni-mainz.de but I want to set this to galaxy@imb-mainz.de.
A quick check shows that the send_mail function defined in lib/galaxy/util/__init__.py is called in various places.
Is there a way to set the "from" to a specific value?
If not, it send_mail the only galaxy-function used to send mail?
Cheers, Holger
-- Dr. Holger Klein Core Facility Bioinformatics Institute of Molecular Biology gGmbH (IMB) http://www.imb-mainz.de/ Tel: +49(6131) 39 21511 ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at:
-- Dr. Holger Klein Core Facility Bioinformatics Institute of Molecular Biology gGmbH (IMB) http://www.imb-mainz.de/ Tel: +49(6131) 39 21511 ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at:
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
participants (3)
-
Dannon Baker
-
Enis Afgan
-
Holger Klein