ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

Authentication failed when fetching mail from IMAP

Added by Luke Carrier at 2012-08-29 03:07 pm

Hi all,

I've been trying to configure IMAP as a means of submitting tickets and notes, but I seem to be hitting a brick wall. I'm using Gmail as the IMAP host (we already have SMTP configured there). I first hit roadblocks with my certificate bundle on my machine causing certificate verification to fail, but I've (temporarily!) worked around this by requiring the openssl library and disabling verification. Although I can verify that the authentication credentials are correct and that I can authenticate perfectly on another client, I can't get the below to work:

 1#!/usr/bin/env bash
 2# Sync emails with IMAP server
 3
 4export PATH="$HOME/.rbenv/bin:$PATH" 
 5export RAILS_ENV=production
 6cd "$HOME/production" 
 7eval "$(rbenv init -)" 
 8bundle exec rake \
 9    --trace \
10    -r 'openssl' -E 'OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE' \
11    redmine:email:receive_imap \
12    host=imap.google.com port=993 ssl=1 \
13    username=xxx@yyy.zzz password=xxx \
14    move_on_success=read move_on_failure=failed

I keep getting authentication failed errors:

[chiliproject@dev production]$ ../scripts/sync_email.sh
(eval):1: warning: already initialized constant VERIFY_PEER
** Invoke redmine:email:receive_imap (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:email:receive_imap
rake aborted!
Authentication failed.
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/imap.rb:1141:in `get_tagged_response'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/imap.rb:1195:in `block in send_command'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/imap.rb:1177:in `send_command'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/imap.rb:419:in `login'
/home/chiliproject/production/lib/redmine/imap.rb:27:in `check'
/home/chiliproject/production/lib/tasks/email.rake:131:in `block (3 levels) in <top (required)>'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:205:in `call'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:200:in `each'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_level'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:94:in `each'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/chiliproject/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/home/chiliproject/.rbenv/versions/1.9.3-p194/bin/rake:32:in `<main>'
Tasks: TOP => redmine:email:receive_imap

I tried Googling around to no avail. Can anybody help me with this?


Replies (3)

RE: Authentication failed when fetching mail from IMAP - Added by Kris Lou at 2012-08-29 07:24 pm

My cron job just runs the following (edited):

cd /path/to/env && \
bundle exec rake -f /path/to/env/Rakefile redmine:email:receive_imap \
RAILS_ENV="production" \
host=imap.gmail.com \
username=XXX@yyy.com password=XXX \
ssl=true port=993 --silent

RE: Authentication failed when fetching mail from IMAP - Added by Felix Schäfer at 2012-08-30 09:11 am

Mmh, that looks more like an error in net/imap, have you tried googling for the error itself?

RE: Authentication failed when fetching mail from IMAP - Added by Luke Carrier at 2012-08-30 11:37 am

Shortening the password and ensuring it contained only alphanumeric characters seems to be a work around. I'll take a wild guess that it's a quirk in the IMAP server we're using as opposed to a bug in the imap library. Thanks for all your help guys! I've pasted the final solution below in case anybody finds it helpful (the documentation is a little lacking for such a great feature).

 1#!/usr/bin/env bash
 2# Sync emails with IMAP server
 3
 4export PATH="$HOME/.rbenv/bin:$PATH" 
 5export RAILS_ENV=production
 6cd "$HOME/production" 
 7eval "$(rbenv init -)" 
 8bundle exec rake \
 9    -r 'openssl' -E 'OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE' \
10    --trace \
11    redmine:email:receive_imap \
12    host=xxx port=993 \
13    ssl=1 \
14    username=xxx password=xxx \
15    allow_override=tracker,priority,project,category,assigned_to,fixed_version,start_date,due_date,estimated_hours,done_ratio \
16    delete_unprocessed=1 \
17    unknown_user=ignore

(1-3/3)