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
Updated by T. Hauptman over 10 years ago
+1
I just had this problem and the patch fixed it for me.
Updated by Jean-Baptiste Barth over 10 years ago
- Assignee set to Jean-Baptiste Barth
- Target version set to Candidate for next minor release
Looks good to me. Can you confirm it is automatically activated by Net::IMAP depending on the port ? I mean, if port is 993, I think starttls is performed automatically. My question is just for improving task description, the rest looks OK.
Updated by Jan Pipek over 10 years ago
Dear Jean-Baptiste,
my patch does not do any guessing (I believe default port is 143), it is up to the user to select SSL or TLS or nothing AND the port (see the redmine/imap.rb code), but it can be implemented easily, for sure.
Updated by Dmitry Kushpet almost 10 years ago
+1
Really useful idea.
Same problem. Patch helped.
Updated by Jean-Philippe Lang almost 10 years ago
- Subject changed from IMAP TLS support (with proposed patch) to IMAP STARTTLS support
- Status changed from New to Closed
- Target version changed from Candidate for next minor release to 3.0.0
- Resolution set to Fixed
Patch applied, with tls option renamed to starttls. Thanks.
Updated by Marcel Müller almost 10 years ago
Jean-Philippe: Just wanted to make sure that this line is actually correct?! With your renaming to "starttls" shouldn't that be
starttls = !imap_options[:starttls].nil?
instead of
starttls = !imap_options[:tls].nil?
Updated by Toshi MARUYAMA almost 10 years ago
Marcel Müller wrote:
With your renaming to "starttls" shouldn't that be
[...]
instead of
[...]
I have created #19232.
Updated by Go MAEDA almost 10 years ago
- Related to Defect #19232: IMAP STARTTLS options typo :tls added