Project

General

Profile

Actions

Defect #8651

closed

Email attachments from Apple Mail are not added to issues any more in v1.2

Added by Roderik van der Veer over 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
-
Category:
Email receiving
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

I've upgraded to 1.2.0 from 1.1.3 last week, and since then, no attachments are added to issues anymore. This worked without any issues before the update, so either i forgot something in the upgrade process, or it's broken :) I've marked this defect as Urgent since we use this functionality a lot with our customers when reporting issues.

Uploading the same attachments (images) through the webinterface works. The permissions on the files folder are 777. I also tried without the lightbox plugin.

My command is: rake -f /home/projects/kmine/data/Rakefile redmine:email:receive_imap RAILS_ENV=production folder=xxx project=xxx tracker=issue category=email host=imap.gmail.com ssl=true port=993 username="xxx" password=xxx unknown_user=accept no_permission_check=1

I tried running with --verbose and --trace, but no useful info is shown.
Also did not see much in http://www.redmine.org/projects/redmine/repository/revisions/5940/changes/trunk/lib/tasks/email.rake

Other settings:

Storing outgoing emails configuration in config/email.yml is deprecated. You should now store it in config/configuration.yml using the email_delivery setting.
About your application's environment
Ruby version 1.8.7 (x86_64-linux)
RubyGems version 1.3.5
Rack version 1.1
Rails version 2.3.11
Active Record version 2.3.11
Active Resource version 2.3.11
Action Mailer version 2.3.11
Active Support version 2.3.11
Edge Rails revision unknown
Application root /home/projects/kmine/data
Environment production
Database adapter mysql
Database schema version 20110511000000

About your Redmine plugins
Redmine Light Box plugin 0.0.1


Files

alexk-3.eml.gz (17.4 KB) alexk-3.eml.gz Alex Shulgin, 2011-07-15 15:38
8651.patch (403 Bytes) 8651.patch Daan Poron, 2011-07-15 16:10
Actions #1

Updated by Roderik van der Veer over 13 years ago

We did some additional debugging and testing (several hours worth :))

"Forwarded email" is always the same one, but we did these tests with multiple emails

New email from Thunderbird on Linux, HTML mail, file attached, no inline image in footer: everything ok
New email from Apple Mail on OSX, HTML mail, file attached, no inline image: everything ok
New email from Apple Mail on OSX, HTML mail, file attached, inline image: no attachments (no image, and no file)
New email from Apple Mail on OSX, Plain Text mail, file attached, inline image: everything ok
Forwarded email, originated on Apple Mail on OSX, HTML, no inline image, file attached, forwarded on Thunderbird on Linux as HTML: everything ok
Forwarded email, originated on Apple Mail on OSX, HTML, no inline image, file attached, forwarded on Apple Mail OSX as HTML: no attachments
Forwarded email, originated on Apple Mail on OSX, HTML, no inline image, file attached, forwarded on Apple Mail OSX as Plain text: everything OK
Forwarded email, originated on Apple Mail on OSX, HTML, no inline image, file attached, forwarded on Mail on iOS (ipad/iPhone), don't know the format, i guess html, no inline image, file attached: no attachments
New email from Mail on iOS, format unknown, file attached: everything ok.

So in conclusion, as soon as there are inline attachments like Apple does them, no attachments will be added.

I've got a workaround for now by converting them into plain text, but i cannot use the system anymore for customers to send in their bugs with screenshots and i cannot dispatch incoming emails from my iOS devices.

We tried debugging (we are not Ruby programmers but we are programmers :)) but as far as we can determine the issue is in ActionMailer

Actions #2

Updated by Daan Poron over 13 years ago

I did some further debugging, the problem lies in ActionMailer and has something to do with how Apple Mail handles boundaries. In Tmail::Mail it will read create an object of the mail received. Here it will check for attachments using the boundaries used in mails to separate multiple parts. The problem we are having with Apple Mail is that the boundary defined in the header of the mail is different then for the Actual attachments.

In the header we have this boudary defined:
Content-Type: multipart/alternative; boundary="Apple-Mail=_E8397270-291C-4746-8EB1-D568A0ABA967"

Our plain text mail is separated using the right boundary:
--Apple-Mail=_E8397270-291C-4746-8EB1-D568A0ABA967

But then our attachments are separated using this boundary:
--Apple-Mail=_DA9B1844-6394-4218-88C6-9A692179991E

Before the Attachments We have this part which defines a new boundry:
--Apple-Mail=_E8397270-291C-4746-8EB1-D568A0ABA967
Content-Type: multipart/mixed;
boundary="Apple-Mail=_DA9B1844-6394-4218-88C6-9A692179991E"

I tried checking the code of TMail::Mail in the method read_multipart but i am not sure if this is done recursively. As Roderik said before we are not experienced Ruby programmers :)

Kind regards,
Daan

Actions #3

Updated by Roderik van der Veer over 13 years ago

We ran a test with an old version of redmine using rails 2.3.5. Redmine 1.0.0.devel.3898 (MySQL)
and the same emails work flawlessly there.

I've gotten new emails with the same problems from other clients, so i'm fairly sure it's not an issue with my system :)

Actions #4

Updated by Daan Poron over 13 years ago

Fixed it by making a small change in the mail_handler model. I added '|| email.multipart?' to the if-statement. The problem for as far as i understand it, is that has_attachments doesn't check for attachments recursively as i tried to explain before. When a multipart mail, has a multipart part with an attachment in the multipart part, then it won't find this. by checking if the mail is multipart, it will get all the attachments, and creates them. The function to get all the attachments in TMail does look for attachments recursively so it will find the deeper nested attachments.

Actions #5

Updated by Jean-Philippe Lang over 13 years ago

Can you provide a patch for this change and a raw email with such an attachment so I can add a test case?

Actions #6

Updated by Alex Shulgin over 13 years ago

Jean-Philippe Lang wrote:

Can you provide a patch for this change and a raw email with such an attachment so I can add a test case?

We're also affected by this bug. Only HTML emails originating from Apple's Mail.app seem to cause the problem.

Attached is a sample raw email (gzipped) with all headers which triggers the problem.

In my understanding the problem lies within TMail's has_attachments? code. If I load the mail into TMail::Mail object, I can see that attachments list is non-empty, but has_attachments? give false, so the attachments list is never considered by redmine mail handler.

$ ./script/console 
Loading development environment (Rails 2.3.11)
>> mail=TMail::Mail.load('/.../alexk-3.eml')
=> #<TMail::Mail port=#<TMail::FilePort:/.../alexk-3.eml> bodyport=nil>
>> mail.has_attachments?
=> false
>> mail.attachments
=> [#<TMail::Attachment:0xa4dff80>]

I've also filed this issue against Rails, here: https://github.com/rails/rails/issues/2051

Actions #7

Updated by Daan Poron over 13 years ago

I tried making a patch, not sure this will work, patch can be found as attachment. You should patch mail_handler.rb in app/models/

Actions #8

Updated by Jean-Philippe Lang over 13 years ago

  • Status changed from New to Resolved
  • Target version set to 1.2.2
  • Resolution set to Fixed

Thanks, I was able to reproduce with the example email.
Fixed and test added in r6324.

Actions #9

Updated by Jean-Philippe Lang over 13 years ago

r6324 broke all other tests. r6325 is just fine.

Actions #10

Updated by Jean-Philippe Lang about 13 years ago

  • Status changed from Resolved to Closed

Merged in r7766.

Actions #11

Updated by Jean-Philippe Lang about 13 years ago

  • Subject changed from Email attachments are not added to issues any more in v1.2 to Email attachments from Apple Mail are not added to issues any more in v1.2
Actions

Also available in: Atom PDF