I'm looking for a part-time remote job.

Hire me


I'm the author of:

Mastering Redmine is a comprehensive guide with tips, tricks and best practices, and an easy-to-learn structure.

Check the book's project or

Buy the book

Social pages of the book:

By buying this book you also donate to Redmine (see this page).


Follow me:

Redmine and attachments in emails

In my book I explained, how to configure outgoing (also known as notifications) and incoming emails in Redmine and how to integrate this issue tracker with mail transport agents (this is about incoming emails). But, I completely missed the issues, which Redmine has with attachments for both types of emails. Eventually, I faced these issues in one of the projects, that I worked on.

Attachments in outgoing emails

In its outgoing emails Redmine includes only links to attachments, not the attachments themselves. In most cases, that’s fine, as attachments can be of huge sizes and delivering such attachments to multiple watchers can appear to be a much bigger problem. Besides, sometimes it can be just undesirable for attached files to be available outside the Redmine instance, where they are protected by passwords and permissions. But, attachments can also be used as inline images in contents in this way helping to deliver the sense. And, that’s where the problem lies.

Inline images in outgoing emails are implemented using external links too. These links point to the images on the Redmine server. So, if the corresponding attachment is not public, such links can return a 4xx HTTP error instead of the image. Depending on the email client this can be shown as a failed image (e.g., a box with an error icon) or not shown at all. In some cases, this can make such email notifications lose their sense. For example, check this:

possible-email-content

Even if these images were attached to this email, it could be unclear, which one was the upper and which was the reply to it. Of course, users can always check the corresponding content in Redmine, where inline images will be shown, but, if there is a feature (email notifications, in this case), it should be fully functional. Obviously, without properly working inline images the implementation of email notifications can be considered to be incomplete.

Redmine Email Images

Luckily, the issue with inline images in outgoing emails can be resolved by installing the Redmine Email Images plugin, which was originally created by Dima Kalachov. This plugin makes Redmine embed copies of such images into the email, so that the email client won’t need to load them from Redmine.

But, for some reason in addition to this Dima’s plugin removes (at least, at this moment) inline images from incoming emails (why?!), what, in my case, caused crashes in Redmine (due to some problem with charset). This also led to other issues, such as, duplicate entries for emails, which caused the crashes. Luckily, the versions of the plugin, which was forked by INSANEWORKS and then me, do not have these issues. So, these are the versions, that you should use (at least, until Dima fixes his plugin).

My fork also makes it possible to use this plugin with the Issue Mail With Attachments plugin. Otherwise, these plugins conflict.

issue-mail-with-attachments

Issue Mail With Attachments

Solution for the other problem – that attachments are not embedded into outgoing emails – also exists (if this is a problem for you, of course). This one can be resolved with the Issue Mail With Attachments plugin. By default this plugin takes an unusual approach – it sends attachments in a separate dedicated email (into which the main content is not included). But, the normal approach, i.e., attachments in the same email, is also supported.

However, this plugin fixes the problem (again, if it’s a problem) only for issues (not for forum messages and so on). Also, its configuration (see the screenshot to the right) is messed up, at least in my opinion. Thus, to have attachments added to the email with the main content (e.g., issue description) you need to enable both options in its settings – “Enable mail attachments” and “Attach all files to notification”. The later alone does nothing. Till I understood this, I believed, that the normal approach is just not supported by this plugin.

Unfortunately, the Issue Mail With Attachments plugin conflicts with the versions of Redmine Email Images by Dima and INSANEWORKS, so you have either to choose one of these plugins or use my fork of the latter.

Attachments in incoming emails

After a user receives an email notification from Redmine, he/she can click on the Reply button in his/her email client and send a reply to such notification. If Redmine is properly configured (see here or in my book, how to do this), such reply can be then imported into Redmine as a response to the corresponding object – e.g., as a note to the issue or as a reply to the forum topic. All such replies will go to a special email address, which is specified in Redmine, from which Redmine sends its notifications and which is checked by Redmine for new emails (again, if configured so). Moreover, users can also send new messages (i.e., not replies) to such email address – in this case such messages will be imported as new issues.

Certainly, all incoming emails – new messages and replies – can include attachments. If they do, such attachments are imported to the created Redmine objects as well. At least, it was planned to be this way (right, this does not always work).

Incoming emails can also come with inline images. And, it’s important to have them property embedded into the created Redmine objects for the same reason as above – without them the content can become less clear or even completely lose its sense (see the aforementioned example). Unfortunately, Redmine does not properly handle inline images in incoming emails either. Thus, by default Redmine prefers to import the plain text version of the email (email clients usually generate two versions – the plain text one and the rich text one). And, obviously, the plain text version does not contain any inline images – it just can’t do this. Moreover, it looks like, Redmine does not actually try to properly handle inline images even for the rich text version of the email.

Another benefit of rdm-mailhandler.rb

In my book I recommended to use rdm-mailhandler.rb instead of IMAP/POP3 rake tasks (check here, if you are not sure, what are those). There, I also explained benefits of the recommended approach, but missed the most important of them: It appeared, that attachments are not imported from incoming emails, if the IMAP or POP3 rake task is used! This also appeared to be a known issue (check here and here). So, if you want attachments of incoming emails to be added to Redmine, you have to go with rdm-mailhandler.rb. At least, for now – until Redmine guys fix the issue.

Redmine Email Inline Images

It’s a plugin different from Redmine Email Images, which was discussed above, while their names are very similar and both fix issues related to inline images in emails.

A fix for the issue with inline images in incoming emails was made available by the British company credativ, which created the plugin Redmine Email Inline Images for this. This plugin finds inline references to attachments and replaces them with correct Textile image rules.

I assume, this plugin works sometimes, but it did not work for me. Thus, it attempts to analyze the plain text version of the email too, so it may work, if such version is missing (probably, some email clients can send emails without the plain text version) – as only then it switches to the rich text version. Also, in my case it failed to find the attached image even for the HTML version of the email (it was attached to a “related” part of the email, which was inside the “alternative” part, not as its top-level part as expected by the plugin). So, to fix these issues I had to modify this plugin too. The modified version, which also supports Markdown, is available here (on my Github).

 

Comments

Also available in: Atom

Add a comment