Email attachments from Apple Mail are not added to issues any more in v1.2
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
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
Database adapter mysql
Database schema version 20110511000000
About your Redmine plugins
Redmine Light Box plugin 0.0.1
#1 Updated by Roderik van der Veer almost 4 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
#2 Updated by Daan Poron almost 4 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:
But then our attachments are separated using this boundary:
Before the Attachments We have this part which defines a new boundry:
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 :)
#3 Updated by Roderik van der Veer almost 4 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 :)
#4 Updated by Daan Poron almost 4 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.
#6 Updated by Alex Shulgin almost 4 years ago
- File alexk-3.eml.gz added
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