[NEW] direct reply by subject
This PR is motivated by adding an alternate method in order to direct reply to offline messages via email using the email subject instead of the email to.
Current situation
The Rocket.Chat message (ID) to reply to is currently referenced using email subaddressing (RFC 5233). Unfortunately there are a lot of email service providers out there not supporting subaddressing (e.g. Microsoft O365). Therefore it might be a good idea to use the subject email header in order to pass the message id.
Changes
This PR makes it configureable to choose whether to use subaddressing or the email subject within your email reply in order to reference the Rocket.Chat message:

How it works
If the Subject option is selected the subject of a reply email will be appended by reply:<17-char-messageID> (see app/lib/server/functions/notifications/email.js for details):
if (settings.get('Direct_Reply_Method') && settings.get('Direct_Reply_Method') === 'subject') {
emailSubject = `${ emailSubject } reply:${ message._id }`;
}
The email interceptor now tries to find a RC messageId either in the e-mail subject or the e-mail to (see /app/lib/server/lib/processDirectEmail.js for details):
const ind = email.headers.subject.indexOf('reply:');
if (ind > 0) {
// message id to reply to is encoded by email 'subject'
email.headers.mid = email.headers.subject.substring(ind + 6, ind + 23);
} else if (email.headers.to.indexOf('+') >= 0) {
// message id to reply to is encoded by email 'to'
// Valid 'To' format
email.headers.mid = email.headers.to.split('@')[0].split('+')[1];
}
@Hudell would be great to see this reviewed! Thanks in advance.
Could we get this feature in the master branch, please? Exchange servers do not have the possibility to do subadressing with a delimiter. They would need that option to subadress by subject ID infusion.