commit/galaxy-central: jmchilton: Add smpt_ssl parameter to force SSL SMTP connection from start.

1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0d46133c9045/ Changeset: 0d46133c9045 User: jmchilton Date: 2013-10-18 01:09:55 Summary: Add smpt_ssl parameter to force SSL SMTP connection from start. This is based on a slightly reworked commit from @aswarren (pull request 198). I tweaked it by dropping smtp_from (as discussed in pull request), and fixing a small string versus bool bug. Tested both ways and it seems to work, with any luck though there is a bug in there somewhere and Galaxy admins everywhere will get a break until it is discovered :). Affected #: 3 files diff -r 90547efa211fb9c6480662129591ab28acbc0ffe -r 0d46133c90452dc8815de7057b13548f06beb7bb lib/galaxy/config.py --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -159,6 +159,7 @@ self.smtp_server = kwargs.get( 'smtp_server', None ) self.smtp_username = kwargs.get( 'smtp_username', None ) self.smtp_password = kwargs.get( 'smtp_password', None ) + self.smtp_ssl = kwargs.get( 'smtp_ssl', None ) self.track_jobs_in_database = kwargs.get( 'track_jobs_in_database', 'None' ) self.start_job_runners = listify(kwargs.get( 'start_job_runners', '' )) self.expose_dataset_path = string_as_bool( kwargs.get( 'expose_dataset_path', 'False' ) ) diff -r 90547efa211fb9c6480662129591ab28acbc0ffe -r 0d46133c90452dc8815de7057b13548f06beb7bb lib/galaxy/util/__init__.py --- a/lib/galaxy/util/__init__.py +++ b/lib/galaxy/util/__init__.py @@ -873,19 +873,24 @@ log.error( "Mail is not configured for this Galaxy instance." ) log.info( msg ) return - s = smtplib.SMTP() + smtp_ssl = asbool( config.smtp_ssl ) + if smtp_ssl: + s = smtplib.SMTP_SSL() + else: + s = smtplib.SMTP() s.connect( config.smtp_server ) - try: - s.starttls() - log.debug( 'Initiated SSL/TLS connection to SMTP server: %s' % config.smtp_server ) - except RuntimeError, e: - log.warning( 'SSL/TLS support is not available to your Python interpreter: %s' % e ) - except smtplib.SMTPHeloError, e: - log.error( "The server didn't reply properly to the HELO greeting: %s" % e ) - s.close() - raise - except smtplib.SMTPException, e: - log.warning( 'The server does not support the STARTTLS extension: %s' % e ) + if not smtp_ssl: + try: + s.starttls() + log.debug( 'Initiated SSL/TLS connection to SMTP server: %s' % config.smtp_server ) + except RuntimeError, e: + log.warning( 'SSL/TLS support is not available to your Python interpreter: %s' % e ) + except smtplib.SMTPHeloError, e: + log.error( "The server didn't reply properly to the HELO greeting: %s" % e ) + s.close() + raise + except smtplib.SMTPException, e: + log.warning( 'The server does not support the STARTTLS extension: %s' % e ) if config.smtp_username and config.smtp_password: try: s.login( config.smtp_username, config.smtp_password ) diff -r 90547efa211fb9c6480662129591ab28acbc0ffe -r 0d46133c90452dc8815de7057b13548f06beb7bb universe_wsgi.ini.sample --- a/universe_wsgi.ini.sample +++ b/universe_wsgi.ini.sample @@ -263,6 +263,9 @@ #smtp_username = None #smtp_password = None +# If your SMTP server requires SSL from the beginning of the connection +# smtp_ssl= False + # On the user registration form, users may choose to join the mailing list. # This is the address of the list they'll be subscribed to. #mailing_join_addr = galaxy-announce-join@bx.psu.edu Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org