From 8df5558cd8c98107aea0446f212a1883bc120a6e Mon Sep 17 00:00:00 2001 From: Maxime Petazzoni Date: Sat, 25 Apr 2009 15:26:00 +0200 Subject: Encode the From: and To: email fields in Base64 encoded UTF-8 Email headers are not supposed to be UTF-8 encoded and should be plain us-ascii. This change encodes the From: and To: fields of the emails sent out by feed2imap in Base64, using the =utf-8?b?...?= syntax. --- lib/feed2imap/itemtomail.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb index 27fc362..8744021 100644 --- a/lib/feed2imap/itemtomail.rb +++ b/lib/feed2imap/itemtomail.rb @@ -51,14 +51,19 @@ def item_to_mail(item, index, updated, from = 'Feed2Imap', inline_images = false message = RMail::Message::new if item.creator and item.creator != '' if item.creator.include?('@') - message.header['From'] = item.creator.chomp + hdr_from = item.creator.chomp else - message.header['From'] = "#{item.creator.chomp} " + hdr_from = "#{item.creator.chomp} " end else - message.header['From'] = "#{from} " + hdr_from = "#{from} " end - message.header['To'] = "#{from} " + + hdr_to = "#{from} " + + message.header['From'] = "=?utf-8?b?#{Base64::encode64(hdr_from)}?=" + message.header['To'] = "=?utf-8?b?#{Base64::encode64(hdr_to)}?=" + if item.date.nil? message.header['Date'] = Time::new.rfc2822 else @@ -73,7 +78,7 @@ def item_to_mail(item, index, updated, from = 'Feed2Imap', inline_images = false if subj.needMIME message.header['Subject'] = "=?utf-8?b?#{Base64::encode64(subj).gsub("\n",'')}?=" else - message.header['Subject'] = subj + message.header['Subject'] = subj end end textpart = RMail::Message::new -- cgit v1.2.3