Project

General

Profile

IMAP Email - Can anyone post an example imap checking cron job?

Added by Craig Kollegger almost 16 years ago

I'm still wrapping my head around system administration and trying to get Redmine checking for IMAP email automatically
using a cron job. Would someone be so kind as to post an example shell script they use to run this check (sensitive details removed of course)? Also, how often do people have the system check for new mail? I'm actually using the Bitnami Redmine Stack which is presenting me with some interesting issues (I need to launch the use_redmine command before I can use the rake task to check for mail but the script seems to pause after that command and resume when I exit it... anyone working with a Bitnami Redmine stack?).

Finally, what's the best way to debug the mailer when it's not working? I have it working when an issue is responded to but if I use the switches that turn on after processing (move it to a folder) or the project overrides it gives me an error (Error in IMAP command received by server followed by a slew of other messages). No error is thrown if there is no mail to be checked.

Here's the rake command I am using:

rake redmine:email:receive_imap RAILS_ENV="production" host=mail.mycompany.com username=support+mycompany.com password=XXXXXX project=emailsupport tracker=bug allow_override=project,tracker,priority move_on_success=read move_on_failure=failed

Any ideas would be greatly appreciated!
Craig


Replies (5)

RE: IMAP Email - Can anyone post an example imap checking cron job? - Added by Brennan Johnson almost 16 years ago

Hey Craig,

This is what I use and it works fine.

Script:
$ vi /usr/local/redmine/scripts/redmine-rake-email.sh
#!/bin/bash
export PATH=$PATH:/usr/local/rubygems/bin:/usr/local/rubygems/gems/bin
export RUBYLIB=/usr/local/rubygems/lib
export GEM_HOME=/usr/local/rubygems/gems
cd /usr/local/redmine/ #just because this is my test install location
rake redmine:email:receive_imap RAILS_ENV="production" host={mail.domain} port=7993 username={user@domain} password={password} ssl=1 move_on_success=read move_on_failure=failed project={project_identifier} tracker=Support allow_override=tracker,priority

Make it executable
$ chmod 770 /usr/local/redmine/script/redmine-rake-email.sh

Add it to cron
$ vi /etc/crontab
*/5 * * * * redmine /usr/local/redmine/script/redmine-rake-email.sh > /tmp/redmine-email.log 2>&1

RE: IMAP Email - Can anyone post an example imap checking cron job? - Added by Craig Kollegger almost 16 years ago

Excellent. This was just what I was looking for. Thanks!

RE: IMAP Email - Can anyone post an example imap checking cron job? - Added by robin van emden over 13 years ago

That was the missing info I was looking for - adding the environment variables made the script work - thanks for the heads up.

RE: IMAP Email - Can anyone post an example imap checking cron job? - Added by John Stone almost 11 years ago

Thank you for including your example script, Brennan. The environment setup was what mine was lacking.

What I ended up with in my /home/<me>/bin/redmine_getemail script, which works for a 2.4.3 redmine (w/ruby 2.0.0p353) hosted from my home directory and installed via RVM:

#!/bin/bash
export GEM_HOME=/home/******/.rvm/gems/ruby-2.0.0-p353
export PATH=/home/******/bin:/home/******/.rvm/gems/ruby-2.0.0-p353/bin:/home/******/.rvm/gems/ruby-2.0.0-p353@global/bin:/home/******/.rvm/rubies/ruby-2.0.0-p353/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/*****/.rvm/bin:/home/*****/.rvm/gems/ruby-2.0.0-p247/bin:/home/*****/.rvm/bin:/home/*****/.rvm/bin:/home/*****/.rvm/gems/ruby-2.0.0-p247/bin:/home/*****/.rvm/bin
export GEM_PATH=/home/*****/gems
export IRBRC=/home/*****/.rvm/rubies/ruby-2.0.0-p353/.irbrc
export MY_RUBY_HOME=/home/*****/.rvm/rubies/ruby-2.0.0-p353

/home/******/.rvm/gems/ruby-2.0.0-p353/bin/rake -f /home/******/www/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=imap.gmail.com username=******@gmail.com password=****** port=993 ssl=true 2>&1

I'm sure some of this is overkill but it works now, so I ain't messing with it. ;)

RE: IMAP Email - Can anyone post an example imap checking cron job? - Added by Bruna de Miranda almost 6 years ago

Thank you very much, Brennan, this script worked very well for me!

    (1-5/5)