Project

General

Profile

Anonymous Email using Rake and IMAP

Added by B. Taylor almost 12 years ago

I realize this problem has be asked before, and I've been trying to get this to work. Emails import into redmine and create a ticket if the user is a registered user. Anonymous emails are opened and read, but not imported. Here is the receive mail script I am using.

---------------------------------------------------------------------------------------------
#!/bin/bash
SERVER=******
USER=*******
PASS=*******

rake f /usr/share/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" \
host="$SERVER" \
username="$USER" \
password="$PASS" \
move_on_success=read \
project=sandbox \
tracker=support \
status=New \
priority=Normal \
allow_override=project,tracker,category,subject,status,priority \
unknown_user=allow \
no_permission_check=1
exit $?
--------------------------------------------------------------------------------------------

Any help would be greatly appreciated.

Thank you


Replies (22)

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

I'm not sure why that is struck out....

#!/bin/bash
SERVER=*********
USER=************
PASS=*********

rake -f /usr/share/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" \
host="$SERVER" \
username="$USER" \
password="$PASS" \
move_on_success=read \
project=sandbox \
tracker=support \
status=New \
priority=Normal \
allow_override=project,tracker,category,subject,status,priority \
unknown_user=allow \
no_permission_check=1
exit $?

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Checking Redmine 2.0 (not sure if it works earlier), it looks like you want to use:

unknown_user=ACTION      how to handle emails from an unknown user
ACTION can be one of the following values:
ignore: email is ignored (default)
accept: accept as anonymous user
create: create a user account

And set that to "accept", not "allow".

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

I changed it and still a no go. I'm using Redmine 1.1.2.stable on Debian; so maybe that's the problem. I tried to install from the package for 2.0.4, but I kept getting an error when install the bundle of gems. They wouldn't install so I was doing it manually, and one (i forget the name) refuses to install.

So that's why I'm using the backports package.

Could it be permissions? I have Non-member and anonymous allowed to create issues.

It should be working from what I can ascertain.

Thank you for the response.

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

According to the 1.1.2 commit:

https://bitbucket.org/redmine/redmine-all/src/d54ccde0b5b5/lib/tasks/email.rake

It supports it, hmm.

Maybe run it in development mode, and check out the logs? (logs/development.log, run with RAILS_ENV="development", make sure your database.yml settings are set for development). I'm curious on why it isn't creating it.

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Also: make sure logging is at INFO level, it should print out a lot of logs detailing why it didn't accept it. :)

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

I have zero logging going on...... not sure why.

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Does the user that Redmine is running as have write permissions to the log directory?

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

... probably not... oops.

Also my email.rake is exactly the same as the one you linked.

the owner of the lib directory is www-data:www-data as I am hosting with apache. Should it be another user?

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Yeah I'm figuring that either the e-mail address it's coming from has a disabled account or something equally funny that'll be hard to figure out by taking the shotgun approach to trying to fix this.

The info debug logs will tell us EXACTLY why it's not importing it. :)

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

The owner of the lib directory is www-data:www-data as I am hosting with apache. Should it be another user?

err log directory

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Lib... or log?

If log, nope that is fine, as long as it's got write access. (confirm with an "ls -lh" and make sure the first three columns are xrw or -rw).

Go follow the page about how to set your log level to INFO and run the rake again, make sure RAILS_ENV="development".

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

I'm getting info in my error log, but not the production log located in /usr/share/redmine/log/production.log

permissions are

rw-r--r- 1 www-data www-data 0 Jun 11 15:44 production.log

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Running with 'RAILS_ENV="development"' should put it in /usr/share/redmine/log/development.log.

However, what does your error log say? (And see if you can get that development.log too)

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

The rake command will not complete when changed to development for some odd reason.

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Is your database configured for develop in config/database.yml under "development:"? Make it match the production section.

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

Ok got it.

Tried to process 2 emails, both say

MailHandler: ignoring email from unknown user [email address]
Message 2 can not be processed

MailHandler: ignoring email from unknown user [email address]
Message 4 can not be processed

It's is logging in production too, its just located at /var/log/redmine/default/

Am I not calling the over ride correctly in my script? I did change it to
unknown_user=accept \ but no change

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

The permissions for anonymous user are set to allow:

Add issues
Add notes
Edit issues

Same for non member.

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Can you paste the whole command you're using right now.

As per this code:

https://bitbucket.org/redmine/redmine-all/src/d54ccde0b5b5/app/models/mail_handler.rb

It seems to be falling through detecting "accept".

Permissions should not be enforced, so those can be set to whatever you want for the behavior of your Redmine's web UI.

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

Do you want the script I am using for the rake command, or the mail_handler.rb?

The script is as listed above; it's executable and ran by a cron job.

#!/bin/bash
SERVER=*********
USER=************
PASS=*********

rake -f /usr/share/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" \
host="$SERVER" \
username="$USER" \
password="$PASS" \
move_on_success=read \
project=sandbox \
tracker=support \
status=New \
priority=Normal \
allow_override=project,tracker,category,subject,status,priority \
unknown_user=accept \
no_permission_check=1
exit $?

Attached is a copy of my mail_handler.rb

mail_handler.rb (13.6 KB) mail_handler.rb mail_handler.rb

RE: Anonymous Email using Rake and IMAP - Added by William Roush almost 12 years ago

Hmm I'm getting kinda stumped here, are you sure that is the exact script being run by the cronjob and you didn't copy it and work on the copied version or something during all this? Did you check your crontab?

Just to humor me, what happens when you run that directly in the command line?

You're also sending new e-mails when you try this, not relying on the old e-mails that I believe get marked as read, right?

RE: Anonymous Email using Rake and IMAP - Added by B. Taylor almost 12 years ago

I changed the script to

rake -f /usr/share/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" \
host="$SERVER" \
username="$USER" \
password="$PASS" \
unknown_user=accept \
allow_override=project,tracker,category,subject,status,priority \
no_permission_check=1
  1. move_on_success=read \
  2. project=sandbox \
  3. tracker=support \
  4. status=New \
  5. priority=Normal \
    exit $?

And now it works. Not sure why it makes a difference to list the unknown_user=accept \ directly after the password, but it does. Thank you for all your help. Those numbers are actually just pound signs to comment out the lines.

    (1-22/22)