RedmineReceivingEmails » History » Version 4
Jean-Philippe Lang, 2008-06-25 23:31
emails forwarding
| 1 | 1 | Jean-Philippe Lang | h1. Receiving emails |
|---|---|---|---|
| 2 | |||
| 3 | 4 | Jean-Philippe Lang | {{>toc}} |
| 4 | |||
| 5 | 2 | Jean-Philippe Lang | As of r1572, Redmine can be configured to allow issue creation or comments via email. |
| 6 | 1 | Jean-Philippe Lang | |
| 7 | h2. Setup |
||
| 8 | |||
| 9 | You can configure Redmine to receive emails in one of the following ways. |
||
| 10 | 4 | Jean-Philippe Lang | |
| 11 | h3. Forwarding emails from your email server |
||
| 12 | |||
| 13 | A standalone script can be used to forward incoming emails from your mail server. |
||
| 14 | This script reads a raw email from the standard input and forward it to Redmine via a HTTP request. |
||
| 15 | It can be found in your redmine directory: @extra/mail_handler/rdm-mailhandler.rb@. |
||
| 16 | |||
| 17 | In order to use it, you have to enable the API that receive emails: |
||
| 18 | Go to _Application settings_ -> _Incoming emails_, check *Enable WS for incoming emails* and enter or generate a secret key. |
||
| 19 | |||
| 20 | Copy @rdm-mailhandler.rb@ to your mail server and configure your MTA. |
||
| 21 | |||
| 22 | Example of a Postfix alias: |
||
| 23 | |||
| 24 | <pre> |
||
| 25 | redmine: "|/path/to/rdm-mailhandler.rb --url http://redmine.domain --key mysecretkey" |
||
| 26 | </pre> |
||
| 27 | |||
| 28 | Options: |
||
| 29 | |||
| 30 | * project => identifier of the project the issue should be added to |
||
| 31 | 1 | Jean-Philippe Lang | |
| 32 | h3. Fetching emails from an IMAP server |
||
| 33 | |||
| 34 | A rake task (@redmine:email:receive_imap@) can be used to fetch incoming emails from an IMAP server. |
||
| 35 | |||
| 36 | It accepts the following options: |
||
| 37 | |||
| 38 | * host => IMAP server host (default: 127.0.0.1) |
||
| 39 | * port => IMAP server port (default: 143) |
||
| 40 | * ssl => Set this option to 1 to enable SSL (default: false) |
||
| 41 | * username => IMAP account |
||
| 42 | * password => IMAP password |
||
| 43 | * folder => IMAP folder to read (default: INBOX) |
||
| 44 | |||
| 45 | Other options: |
||
| 46 | |||
| 47 | * project => identifier of the project the issue should be added to |
||
| 48 | |||
| 49 | Example: |
||
| 50 | |||
| 51 | <pre> |
||
| 52 | rake redmine:email:receive_imap host=imap.domain \ |
||
| 53 | username=redmine@domain \ |
||
| 54 | password=xxx \ |
||
| 55 | project=foo \ # => all issues will be added to project "foo" |
||
| 56 | RAILS_ENV="production" |
||
| 57 | </pre> |
||
| 58 | |||
| 59 | Emails that are ignored (unknown user, unknown project...) are marked as 'Seen' but are not deleted from the IMAP server. |
||
| 60 | |||
| 61 | h3. Reading emails from standard input |
||
| 62 | |||
| 63 | A rake task (@redmine:email:receive@) can be used to read a single raw email from the standard input. |
||
| 64 | |||
| 65 | Options: |
||
| 66 | |||
| 67 | * project => identifier of the project the issue should be added to |
||
| 68 | |||
| 69 | Postfix or Sendmail can be configured to forward incoming emails to this script. |
||
| 70 | See: http://wiki.rubyonrails.org/rails/pages/HowToReceiveEmailsWithActionMailer |
||
| 71 | |||
| 72 | Example of a Postfix alias: |
||
| 73 | |||
| 74 | redmine: "|(cd /path/to/redmine && rake redmine:email:receive RAILS_ENV=production)" |
||
| 75 | |||
| 76 | |||
| 77 | h2. How it works |
||
| 78 | |||
| 79 | 3 | Jean-Philippe Lang | When receiving an email, Redmine uses the From address of the email to find the corresponding user. Emails received from unknow or locked users are ignored. |
| 80 | 1 | Jean-Philippe Lang | |
| 81 | 3 | Jean-Philippe Lang | If the email subject contains something like "Re: *[xxxxxxx !#123]*", the email is processed as a reply and a note is added to issue !#123. Otherwise, a new issue is created. |
| 82 | 1 | Jean-Philippe Lang | |
| 83 | 3 | Jean-Philippe Lang | If you don't use the @project@ option when reading emails, users have to specify in the email body which project the issue should be added to. This can be done by inserting a line in the email body like this: @"Project: foo"@. |
| 84 | 1 | Jean-Philippe Lang | |
| 85 | Example (email body): |
||
| 86 | |||
| 87 | <pre> |
||
| 88 | This is a new ticket that will be added to project foo. |
||
| 89 | Here we have the ticket description |
||
| 90 | [...] |
||
| 91 | |||
| 92 | Project: foo |
||
| 93 | </pre> |
||
| 94 | |||
| 95 | 3 | Jean-Philippe Lang | Of course, user permissions are checked and this email would be ignored if the user who sent this email is not allowed to add issues to project foo. |