Project

General

Profile

RedmineReceivingEmails » History » Version 6

Jean-Philippe Lang, 2008-07-06 18:40

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 6 Jean-Philippe Lang
</pre>
45
46 1 Jean-Philippe Lang
Examples:
47 6 Jean-Philippe Lang
48
<pre>
49 5 Jean-Philippe Lang
  # No project specified. Emails MUST contain the 'Project' keyword:
50
  rdm-mailhandler --url http://redmine.domain.foo --key secret
51
  
52
  # Fixed project and default tracker specified, but emails can override
53
  # both tracker and priority attributes:
54
  rdm-mailhandler --url https://domain.foo/redmine --key secret \\
55
                  --project foo \\
56
                  --tracker bug \\
57
                  --allow-override tracker,priority
58
</pre>
59
60
Here is an example for a Postfix alias:
61
62
<pre>
63
foo: "|/path/to/rdm-mailhandler.rb --url http://redmine.domain --key secret --project foo"
64
</pre> 
65 1 Jean-Philippe Lang
66
h3. Fetching emails from an IMAP server
67
68
A rake task (@redmine:email:receive_imap@) can be used to fetch incoming emails from an IMAP server.
69
70 6 Jean-Philippe Lang
<pre>
71
Available IMAP options:
72
  host=HOST                IMAP server host (default: 127.0.0.1)
73
  port=PORT                IMAP server port (default: 143)
74
  ssl=SSL                  Use SSL? (default: false)
75
  username=USERNAME        IMAP account
76
  password=PASSWORD        IMAP password
77
  folder=FOLDER            IMAP folder to read (default: INBOX)
78 1 Jean-Philippe Lang
79 6 Jean-Philippe Lang
Issue attributes control options:
80
  project=PROJECT          identifier of the target project
81
  tracker=TRACKER          name of the target tracker
82
  category=CATEGORY        name of the target category
83
  priority=PRIORITY        name of the target priority
84
  allow_override=ATTRS     allow email content to override attributes
85
                           specified by previous options
86
                           ATTRS is a comma separated list of attributes
87
  
88
</pre>
89 1 Jean-Philippe Lang
90 6 Jean-Philippe Lang
Examples:
91 1 Jean-Philippe Lang
92 6 Jean-Philippe Lang
<pre>
93
  # No project specified. Emails MUST contain the 'Project' keyword:
94
  
95
  rake redmine:email:receive_iamp RAILS_ENV="production" \\
96
    host=imap.foo.bar username=redmine@somenet.foo password=xxx
97 1 Jean-Philippe Lang
98
99 6 Jean-Philippe Lang
  # Fixed project and default tracker specified, but emails can override
100
  # both tracker and priority attributes:
101
  
102
  rake redmine:email:receive_iamp RAILS_ENV="production" \\
103
    host=imap.foo.bar username=redmine@somenet.foo password=xxx ssl=1 \\
104
    project=foo \\
105
    tracker=bug \\
106
    allow_override=tracker,priority
107 1 Jean-Philippe Lang
</pre>
108
109 6 Jean-Philippe Lang
110 1 Jean-Philippe Lang
Emails that are ignored (unknown user, unknown project...) are marked as 'Seen' but are not deleted from the IMAP server.
111
112
h3. Reading emails from standard input
113
114
A rake task (@redmine:email:receive@) can be used to read a single raw email from the standard input.
115
116 6 Jean-Philippe Lang
<pre>
117
Issue attributes control options:
118
  project=PROJECT          identifier of the target project
119
  tracker=TRACKER          name of the target tracker
120
  category=CATEGORY        name of the target category
121
  priority=PRIORITY        name of the target priority
122
  allow_override=ATTRS     allow email content to override attributes
123
                           specified by previous options
124
                           ATTRS is a comma separated list of attributes
125
</pre>
126 1 Jean-Philippe Lang
127 6 Jean-Philippe Lang
Examples:
128 1 Jean-Philippe Lang
129 6 Jean-Philippe Lang
<pre>
130
  # No project specified. Emails MUST contain the 'Project' keyword:
131
  rake redmine:email:read RAILS_ENV="production" < raw_email
132 1 Jean-Philippe Lang
133 6 Jean-Philippe Lang
  # Fixed project and default tracker specified, but emails can override
134
  # both tracker and priority attributes:
135
  rake redmine:email:read RAILS_ENV="production" \\
136
                  project=foo \\
137
                  tracker=bug \\
138
                  allow_override=tracker,priority < raw_email
139
</pre>
140 1 Jean-Philippe Lang
141
142
h2. How it works
143
144
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.
145
146
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.
147 3 Jean-Philippe Lang
148 1 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"@.
149
150
Example (email body):
151
152
<pre>
153
This is a new ticket that will be added to project foo.
154
Here we have the ticket description
155
[...]
156
157
Project: foo
158
</pre>
159
160
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.