diff options
author | Maxime Petazzoni <maxime.petazzoni@bulix.org> | 2009-04-25 15:26:00 +0200 |
---|---|---|
committer | Lucas Nussbaum <lucas@lucas-nussbaum.net> | 2009-05-05 11:18:35 +0200 |
commit | 8df5558cd8c98107aea0446f212a1883bc120a6e (patch) | |
tree | 9a60b8e1a95eb3888ded10c45a86f39cd7c79ad4 /lib/feed2imap/itemtomail.rb | |
parent | eb91d4339dd9d56e39f5a45fca9652d7844ab175 (diff) | |
download | feed2imap-8df5558cd8c98107aea0446f212a1883bc120a6e.tar.gz feed2imap-8df5558cd8c98107aea0446f212a1883bc120a6e.tar.bz2 feed2imap-8df5558cd8c98107aea0446f212a1883bc120a6e.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | lib/feed2imap/itemtomail.rb | 15 |
1 files 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} <feed2imap@acme.com>" + hdr_from = "#{item.creator.chomp} <feed2imap@acme.com>" end else - message.header['From'] = "#{from} <feed2imap@acme.com>" + hdr_from = "#{from} <feed2imap@acme.com>" end - message.header['To'] = "#{from} <feed2imap@acme.com>" + + hdr_to = "#{from} <feed2imap@acme.com>" + + 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 |