From 8d4be556a2d49d28506665a820ed6bc166dbdc0d Mon Sep 17 00:00:00 2001 From: Lucas Nussbaum Date: Wed, 6 May 2009 14:55:35 +0200 Subject: use multipart/related only if there are images ... and only use multipart/alternative in the other case. --- lib/feed2imap/itemtomail.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/feed2imap/itemtomail.rb') diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb index ffa6b22..0f97ac0 100644 --- a/lib/feed2imap/itemtomail.rb +++ b/lib/feed2imap/itemtomail.rb @@ -87,14 +87,8 @@ def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, w htmlpart.body = item.to_html # inline images as attachments + imgs = [] if inline_images - message.header.set('Content-Type', 'multipart/related', 'type'=> 'multipart/alternative') - texthtml = RMail::Message::new - texthtml.header.set('Content-Type', 'multipart/alternative') - texthtml.add_part(textpart) - texthtml.add_part(htmlpart) - message.add_part(texthtml) - cids = [] htmlpart.body.gsub!(/(]+)src="(\S+?\/([^\/]+?\.(png|gif|jpe?g)))"([^>]*>)/i) do |match| # $2 contains url, $3 the image name, $4 the image extension @@ -111,7 +105,7 @@ def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, w imgpart.header.set('Content-Disposition', 'attachment', 'filename' => $3) imgpart.header.set('Content-Transfer-Encoding', 'base64') imgpart.body = image - message.add_part(imgpart) + imgs << imgpart end # now to specify what to replace with newtag = "#{$1}src=\"cid:#{cid}\"#{$5}" @@ -122,6 +116,17 @@ def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, w $& # don't modify on exception end end + end + if imgs.length > 0 + message.header.set('Content-Type', 'multipart/related', 'type'=> 'multipart/alternative') + texthtml = RMail::Message::new + texthtml.header.set('Content-Type', 'multipart/alternative') + texthtml.add_part(textpart) + texthtml.add_part(htmlpart) + message.add_part(texthtml) + imgs.each do |i| + message.add_part(i) + end else message.header['Content-Type'] = 'multipart/alternative' message.add_part(textpart) -- cgit v1.2.3-70-g09d2 a href='/portato.git/log/?id=c0b751facc2dd5ca6dc6bf15a855e4d22dd24356&follow=1'>root/portato/plugins/new_version.py (unfollow)
Commit message (Expand)AuthorFilesLines
2008-06-23Reverted last commit; Added get and set methodRené 'Necoro' Neumann1-11/+19
2008-06-23Make Session inherit from ConfigParser. This allows the usage of normal confi...René 'Necoro' Neumann1-9/+10
2008-06-23German translationRené 'Necoro' Neumann2-144/+228
2008-06-23Finished send_mail workRené 'Necoro' Neumann2-52/+68
2008-06-23Added plugin, which simply throws an exceptionRené 'Necoro' Neumann2-0/+15
2008-06-23Fixed name of gpytage pluginRené 'Necoro' Neumann1-1/+1
2008-06-23Moved GtkThread to gui.utilsRené 'Necoro' Neumann5-29/+25
2008-06-22Implemented the mail sendingRené 'Necoro' Neumann2-3/+63
2008-06-22First mail window draftRené 'Necoro' Neumann3-0/+220
2008-06-10Added gpytage pluginRené 'Necoro' Neumann2-0/+29
2008-06-10Modified plugin.xsd so it allows also menu-only pluginsRené 'Necoro' Neumann2-7/+8
2008-06-10Fixed the default handlingRené 'Necoro' Neumann1-1/+1
2008-06-10Allowed default for session; load 'app-portage/portato' as default for select...René 'Necoro' Neumann2-10/+18
2008-06-09Fixed 'kill' in the systray popupRené 'Necoro' Neumann1-2/+2
2008-06-09Fixed error messageRené 'Necoro' Neumann2-4/+1
2008-06-08Make blocks way more intelligentRené 'Necoro' Neumann3-45/+107