Vote #75207
完了IMAP STARTTLS support
0%
説明
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
journals
+1
I just had this problem and the patch fixed it for me.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
+1
Really useful idea.
Same problem. Patch helped.
--------------------------------------------------------------------------------
Patch applied, with tls option renamed to starttls. Thanks.
--------------------------------------------------------------------------------
Jean-Philippe: Just wanted to make sure that "this":http://www.redmine.org/projects/redmine/repository/revisions/13950/entry/trunk/lib/redmine/imap.rb#L27 line is actually correct?! With your renaming to "starttls" shouldn't that be
<pre>
starttls = !imap_options[:starttls].nil?
</pre>
instead of
<pre>
starttls = !imap_options[:tls].nil?
</pre>
--------------------------------------------------------------------------------
Marcel Müller wrote:
> With your renaming to "starttls" shouldn't that be
> [...]
> instead of
> [...]
I have created #19232.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
related_issues
relates,Closed,19232,IMAP STARTTLS options typo :tls