RedmineReceivingEmails » History » Version 5
Jean-Philippe Lang, 2008-07-06 18:30
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 | 5 | Jean-Philippe Lang | Usage: |
23 | 4 | Jean-Philippe Lang | |
24 | 1 | Jean-Philippe Lang | <pre> |
25 | 5 | Jean-Philippe Lang | rdm-mailhandler [options] --url=<Redmine URL> --key=<API key> |
26 | 1 | Jean-Philippe Lang | |
27 | 5 | Jean-Philippe Lang | Required: |
28 | -u, --url URL of the Redmine server |
||
29 | -k, --key Redmine API key |
||
30 | |||
31 | General options: |
||
32 | -h, --help show this help |
||
33 | -v, --verbose show extra information |
||
34 | -V, --version show version information and exit |
||
35 | 1 | Jean-Philippe Lang | |
36 | 5 | Jean-Philippe Lang | Issue attributes control options: |
37 | -p, --project=PROJECT identifier of the target project |
||
38 | -t, --tracker=TRACKER name of the target tracker |
||
39 | --category=CATEGORY name of the target category |
||
40 | --priority=PRIORITY name of the target priority |
||
41 | -o, --allow-override=ATTRS allow email content to override attributes |
||
42 | specified by previous options |
||
43 | ATTRS is a comma separated list of attributes |
||
44 | |||
45 | Examples: |
||
46 | # No project specified. Emails MUST contain the 'Project' keyword: |
||
47 | rdm-mailhandler --url http://redmine.domain.foo --key secret |
||
48 | |||
49 | # Fixed project and default tracker specified, but emails can override |
||
50 | # both tracker and priority attributes: |
||
51 | rdm-mailhandler --url https://domain.foo/redmine --key secret \\ |
||
52 | --project foo \\ |
||
53 | --tracker bug \\ |
||
54 | --allow-override tracker,priority |
||
55 | </pre> |
||
56 | |||
57 | Here is an example for a Postfix alias: |
||
58 | |||
59 | <pre> |
||
60 | foo: "|/path/to/rdm-mailhandler.rb --url http://redmine.domain --key secret --project foo" |
||
61 | </pre> |
||
62 | 1 | Jean-Philippe Lang | |
63 | h3. Fetching emails from an IMAP server |
||
64 | |||
65 | A rake task (@redmine:email:receive_imap@) can be used to fetch incoming emails from an IMAP server. |
||
66 | |||
67 | It accepts the following options: |
||
68 | |||
69 | * host => IMAP server host (default: 127.0.0.1) |
||
70 | * port => IMAP server port (default: 143) |
||
71 | * ssl => Set this option to 1 to enable SSL (default: false) |
||
72 | * username => IMAP account |
||
73 | * password => IMAP password |
||
74 | * folder => IMAP folder to read (default: INBOX) |
||
75 | |||
76 | Other options: |
||
77 | |||
78 | * project => identifier of the project the issue should be added to |
||
79 | |||
80 | Example: |
||
81 | |||
82 | <pre> |
||
83 | rake redmine:email:receive_imap host=imap.domain \ |
||
84 | username=redmine@domain \ |
||
85 | password=xxx \ |
||
86 | project=foo \ # => all issues will be added to project "foo" |
||
87 | RAILS_ENV="production" |
||
88 | </pre> |
||
89 | |||
90 | Emails that are ignored (unknown user, unknown project...) are marked as 'Seen' but are not deleted from the IMAP server. |
||
91 | |||
92 | h3. Reading emails from standard input |
||
93 | |||
94 | A rake task (@redmine:email:receive@) can be used to read a single raw email from the standard input. |
||
95 | |||
96 | Options: |
||
97 | |||
98 | * project => identifier of the project the issue should be added to |
||
99 | |||
100 | Postfix or Sendmail can be configured to forward incoming emails to this script. |
||
101 | See: http://wiki.rubyonrails.org/rails/pages/HowToReceiveEmailsWithActionMailer |
||
102 | |||
103 | Example of a Postfix alias: |
||
104 | |||
105 | redmine: "|(cd /path/to/redmine && rake redmine:email:receive RAILS_ENV=production)" |
||
106 | |||
107 | |||
108 | h2. How it works |
||
109 | |||
110 | 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. |
111 | 1 | Jean-Philippe Lang | |
112 | 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. |
113 | 1 | Jean-Philippe Lang | |
114 | 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"@. |
115 | 1 | Jean-Philippe Lang | |
116 | Example (email body): |
||
117 | |||
118 | <pre> |
||
119 | This is a new ticket that will be added to project foo. |
||
120 | Here we have the ticket description |
||
121 | [...] |
||
122 | |||
123 | Project: foo |
||
124 | </pre> |
||
125 | |||
126 | 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. |