Feature #16823
closedIMAP STARTTLS support
0%
Description
Dear developers of Redmine,
I was setting up receiving emails along the guidelines in http://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails .
Our IMAP server listens on port 143, but not on the SSL port 993. It does not accept password in PLAIN format by default, for that you have to switch to TLS. Current Redmine code does not enable to configure this :-(
I think this situation might be quite common and so the possibility to use TLS (supported by Net::IMAP) might be appreciated by many users. I am including a patch (basicly a git diff) that proposes the solution by adding another option ('tls') similar to 'ssl'. I am not an expert on mail services so the code clearly has to be evaluated by someone, but at least it works for me (applied on v2.3.2).
diff --git a/lib/redmine/imap.rb b/lib/redmine/imap.rb index 093ac3e..52e1040 100644 --- a/lib/redmine/imap.rb +++ b/lib/redmine/imap.rb @@ -24,9 +24,13 @@ module Redmine host = imap_options[:host] || '127.0.0.1' port = imap_options[:port] || '143' ssl = !imap_options[:ssl].nil? + tls = !imap_options[:tls].nil? folder = imap_options[:folder] || 'INBOX' imap = Net::IMAP.new(host, port, ssl) + if tls + imap.starttls + end imap.login(imap_options[:username], imap_options[:password]) unless imap_options[:username].nil? imap.select(folder) imap.uid_search(['NOT', 'SEEN']).each do |uid| diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake index 934070e..302328d 100644 --- a/lib/tasks/email.rake +++ b/lib/tasks/email.rake @@ -84,6 +84,7 @@ Available IMAP options: host=HOST IMAP server host (default: 127.0.0.1) port=PORT IMAP server port (default: 143) ssl=SSL Use SSL? (default: false) + tls=TLS Use TLS? (default: false) username=USERNAME IMAP account password=PASSWORD IMAP password folder=FOLDER IMAP folder to read (default: INBOX) @@ -124,6 +125,7 @@ END_DESC imap_options = {:host => ENV['host'], :port => ENV['port'], :ssl => ENV['ssl'], + :tls => ENV['tls'], :username => ENV['username'], :password => ENV['password'], :folder => ENV['folder'],
I hope my idea is at least somewhat interesting and useful.
Regards,
Jan
Related issues