Notification Emails cut off due to SMTP protocol specificies
Today I want to share a story of a bug that I dealt with for quite a while now - I guess I first noticed it about a year ago.
We are using Redmine as a project management tool at my company for almost ten years now. About a year ago (maybe it was more, I don't remember), I noticed that some notification emails about issue updates were simply too short: Instead of showing the issue's data fields and the note as usual, I would only get a single line in my inbox:
Issue #22222 has been updated by Nicolas Xxxxxx
First I thought it's just something about the notification / email configuration, and half-heartedly looked at the configuration, but didn't find out anything. It was only happening for some updates, not all of them, so I just lived with the issue. However it was still a bother.
So, a few days ago I started looking into it again. I noticed that in the received emails, the HTML part was cut off very suddenly in the source:
(...) <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8">= (...) Issue <a href=3D"https://www.redmine.my-company.com/issues/22222#change-1= 22826" style=3D"color:#169">#22222</a> has been updated by Nicolas Xxxxxx=
What a sudden stop! And no errors in the logs either!
What was intersting to me was that the last line was exactly the maximum length. So, following my intuition, I looked at all the notification emails I got in the past where the cutoff happened. Interestingly, they were all triggered by people with the same name length!
Following up, I called up one colleague whose name matched the "problematic" length. I renamed his account to a longer first name and had him update a test ticket for me. And what do I see? The notification works! Here's how that email looks in the source now:
(...) Issue <a href=3D"https://www.redmine.my-company.com/issues/22222#change-1= 22825" style=3D"color:#169">#22222</a> has been updated by Nicolass Xxxxx= x. <hr style=3D"width:100%;height:1px;background:#ccc;border:0;margin:1.2em = 0"> (...)
So - The last name is broken onto the next line, and suddenly the email works???
Luckily, after pondering this for a while, I remembered me messing with mail servers via Telnet back in the day. Wasn't there something about message syntax? How did we end an email after typing in a message? Right - a period alone on a line!
Now it seems that when the issue ID, change ID, URL and Account name line up juuuust right, the rendered email template will put such a period on a line on it's own! And that way, the mail server would accept the first half of the message, send it out, and disregard the rest.
Now, back to Redmine: I don't know if the bug is in Redmine itself, or in the email library used that was supposed to escape such characters, so I'm depositing it here.
I hope you guys get a good grin out of reading this just as I did when I finally discovered the cause of that issue! I'll be glad to help out with more info if needed.
Environment: Redmine version 3.4.12.stable Ruby version 2.3.3-p222 (2016-11-21) [x86_64-linux-gnu] Rails version 18.104.22.168 Environment production Database adapter PostgreSQL