Top Level Namespace
Defined Under Namespace
Classes: CachedChannel, CachedItem, ConfigFeed, F2IConfig, Feed2Imap, HTML2TextParser, HTTPFetcher, ImapAccount, ImapAccounts, ItemCache, MaildirAccount, SGMLParser, String
Constant Summary collapse
- DEFCACHE =
Default cache file
ENV['HOME'] + '/.feed2imap.cache'
- HOSTNAME =
Hostname and login name of the current user
Socket.gethostname
- LOGNAME =
Etc.getlogin
- F2I_WARNFETCHTIME =
Feed2Imap - RSS/Atom Aggregator uploading to an IMAP Server Copyright © 2005 Lucas Nussbaum <lucas@lucas-nussbaum.net>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
10- MAXREDIR =
max number of redirections
5- HTTPDEBUG =
false
Instance Method Summary collapse
Instance Method Details
#item_to_mail(config, item, id, updated, from = 'Feed2Imap', inline_images = false, wrapto = false) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/feed2imap/itemtomail.rb', line 51 def item_to_mail(config, item, id, updated, from = 'Feed2Imap', inline_images = false, wrapto = false) = RMail::Message::new if item.creator and item.creator != '' if item.creator.include?('@') .header['From'] = item.creator.chomp else .header['From'] = "=?utf-8?b?#{Base64::encode64(item.creator.chomp).gsub("\n",'')}?= <#{config.default_email}>" end else .header['From'] = "=?utf-8?b?#{Base64::encode64(from).gsub("\n",'')}?= <#{config.default_email}>" end .header['To'] = "=?utf-8?b?#{Base64::encode64(from).gsub("\n",'')}?= <#{config.default_email}>" if item.date.nil? .header['Date'] = Time::new.rfc2822 else .header['Date'] = item.date.rfc2822 end .header['X-Feed2Imap-Version'] = Feed2Imap::VERSION .header['Message-Id'] = id .header['X-F2IStatus'] = "Updated" if updated # treat subject. Might need MIME encoding. subj = item.title or (item.date and item.date.to_s) or item.link if subj if subj.needMIME .header['Subject'] = "=?utf-8?b?#{Base64::encode64(subj).gsub("\n",'')}?=" else .header['Subject'] = subj end end textpart = htmlpart = nil parts = config.parts if parts.include?('text') textpart = parts.size == 1 ? : RMail::Message::new textpart.header['Content-Type'] = 'text/plain; charset=utf-8; format=flowed' textpart.header['Content-Transfer-Encoding'] = '8bit' textpart.body = item.to_text(true, wrapto, false) end if parts.include?('html') htmlpart = parts.size == 1 ? : RMail::Message::new htmlpart.header['Content-Type'] = 'text/html; charset=utf-8' htmlpart.header['Content-Transfer-Encoding'] = '8bit' htmlpart.body = item.to_html_with_headers end # inline images as attachments imgs = [] if inline_images htmlpart.body.gsub!(/(<img[^>]+)src="(\S+?\/([^\/]+?\.(png|gif|jpe?g)))"([^>]*>)/i) do |match| # $2 contains url, $3 the image name, $4 the image extension begin fetcher = HTTPFetcher.new image = Base64.encode64(fetcher.fetch($2, Time.at(0)).chomp) "#{$1}src=\"data:image/#{$4};base64,#{image}\"#{$5}" rescue #print "Error while fetching image #{$2}: #{$!}...\n" $& # don't modify on exception end end end if imgs.length > 0 .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) .add_part(texthtml) imgs.each do |i| .add_part(i) end elsif parts.size != 1 .header['Content-Type'] = 'multipart/alternative' .add_part(textpart) .add_part(htmlpart) end return .to_s end |