Feature #23011
closedPurpose of MESSAGE_ID_RE in mail_handler.rb
Description
In `dispatch` of `app/models/mail_handler.rb` a global named `MESSAGE_ID_RE` is used, which is defined as the regular expression:
MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}
The conditional in `dispatch` does the following:
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
klass, object_id = $1, $2.to_i
method_name = "receive_#{klass}_reply"
if self.class.private_instance_methods.collect(&:to_s).include?(method_name)
send method_name, object_id
else
# ignoring it
end
end
The purpose of this global (and its conditional in `dispatch`) isn't quite clear to me, as it is also lacking comments. I suspect that it looks for redmine's own e-mail-address and then calls a supplied method?
Why should redmine talk to itself through e-mails in such a way? What if I change redmine's e-mail-address to something not containing redmine? What will break (if anything)?
We recently changed the naming of our redmine instance (both the domain-name and the e-mail-address now do not contain redmine) to something more obvious for non-tech folk. We would hate to have broken something by that change.
Updated by Jean-Philippe Lang almost 10 years ago
- Status changed from New to Closed
In-Reply-To and References headers when a user replies to a Redmine notification in order to know to which object (issue or message) the user is replying:
- Redmine sends a notification (eg. issue X is created)
- A user replies to this notification
- Redmine detects that this is a reply to issue X and appends the message as a note to issue X
It doesn't match the host part of the message id, so changing your hostname should not have any effects on this.
Updated by Alexander Herr almost 10 years ago
And what if not only the domain does not contain redmine but the e-mail-name as well? I.e. instead of redmine@domain.com its ticket@domain.com. Does that break the above?
Updated by Jean-Philippe Lang almost 10 years ago
Alexander Herr wrote:
And what if not only the domain does not contain redmine but the e-mail-name as well? I.e. instead of redmine@domain.com its ticket@domain.com. Does that break the above?
No
Updated by Jean-Philippe Lang almost 10 years ago
This regexp is not for parsing email addresses but message ids which are always generated by Redmine in this way: <redmine-xxx@xxx>, whatever your host name or email address is (see Mailer#message_id_for and Mailer#token_for).