summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--data/doc/feed2imap/examples/feed2imaprc1
-rw-r--r--lib/feed2imap/config.rb10
-rw-r--r--lib/feed2imap/feed2imap.rb8
-rw-r--r--lib/feed2imap/itemtomail.rb10
4 files changed, 19 insertions, 10 deletions
diff --git a/data/doc/feed2imap/examples/feed2imaprc b/data/doc/feed2imap/examples/feed2imaprc
index ca5c030..8d732ba 100644
--- a/data/doc/feed2imap/examples/feed2imaprc
+++ b/data/doc/feed2imap/examples/feed2imaprc
@@ -7,6 +7,7 @@
# debug-updated: (for debugging purposes) if true, display a lot of information
# about the "updated-items" algorithm.
# include-images: download images and include them in the mail? (true/false)
+# default-email: default email address in the format foo@example.com
#
# Per-feed options:
# name: name of the feed (must be unique)
diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb
index 5f6f448..a9c796c 100644
--- a/lib/feed2imap/config.rb
+++ b/lib/feed2imap/config.rb
@@ -21,13 +21,19 @@ require 'yaml'
require 'uri'
require 'feed2imap/imap'
require 'feed2imap/maildir'
+require 'etc'
+require 'socket'
# Default cache file
DEFCACHE = ENV['HOME'] + '/.feed2imap.cache'
+# Hostname and login name of the current user
+HOSTNAME = Socket.gethostname
+LOGNAME = Etc.getlogin
+
# Feed2imap configuration
class F2IConfig
- attr_reader :imap_accounts, :cache, :feeds, :dumpdir, :updateddebug, :max_failures, :include_images
+ attr_reader :imap_accounts, :cache, :feeds, :dumpdir, :updateddebug, :max_failures, :include_images, :default_email, :hostname
# Load the configuration from the IO stream
# TODO should do some sanity check on the data read.
@@ -40,6 +46,8 @@ class F2IConfig
@max_failures = (@conf['max-failures'] || 10).to_i
@updateddebug = (@conf['debug-updated'] and @conf['debug-updated'] != 'false')
@include_images = (@conf['include-images'] and @conf['include-images'] != 'false')
+ @default_email = (@conf['default-email'] || "#{LOGNAME}@#{HOSTNAME}")
+ @hostname = HOSTNAME # FIXME: should this be configurable as well?
@imap_accounts = ImapAccounts::new
maildir_account = MaildirAccount::new
@conf['feeds'].each do |f|
diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb
index 68051c7..f23c0dc 100644
--- a/lib/feed2imap/feed2imap.rb
+++ b/lib/feed2imap/feed2imap.rb
@@ -244,15 +244,15 @@ class Feed2Imap
if !cacherebuild
fn = f.name.gsub(/[^0-9A-Za-z]/,'')
updateditems.each do |i|
- id = "<#{fn}-#{i.cacheditem.index}@acme.com>"
- email = item_to_mail(i, id, true, f.name, f.include_images, f.wrapto)
+ id = "<#{fn}-#{i.cacheditem.index}@#{@config.hostname}>"
+ email = item_to_mail(@config, i, id, true, f.name, f.include_images, f.wrapto)
f.imapaccount.updatemail(f.folder, email,
id, i.date || Time::new)
end
# reverse is needed to upload older items first (fixes gna#8986)
newitems.reverse.each do |i|
- id = "<#{fn}-#{i.cacheditem.index}@acme.com>"
- email = item_to_mail(i, id, false, f.name, f.include_images, f.wrapto)
+ id = "<#{fn}-#{i.cacheditem.index}@#{@config.hostname}>"
+ email = item_to_mail(@config, i, id, false, f.name, f.include_images, f.wrapto)
f.imapaccount.putmail(f.folder, email, i.date || Time::new)
end
end
diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb
index d12d3c5..6c70cbd 100644
--- a/lib/feed2imap/itemtomail.rb
+++ b/lib/feed2imap/itemtomail.rb
@@ -47,18 +47,18 @@ class String
end
end
-def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, wrapto = false)
+def item_to_mail(config, item, id, updated, from = 'Feed2Imap', inline_images = false, wrapto = false)
message = RMail::Message::new
if item.creator and item.creator != ''
if item.creator.include?('@')
message.header['From'] = item.creator.chomp
else
- message.header['From'] = "=?utf-8?b?#{Base64::encode64(item.creator.chomp).gsub("\n",'')}?= <feed2imap@acme.com>"
+ message.header['From'] = "=?utf-8?b?#{Base64::encode64(item.creator.chomp).gsub("\n",'')}?= <#{config.default_email}>"
end
else
- message.header['From'] = "=?utf-8?b?#{Base64::encode64(from).gsub("\n",'')}?= <feed2imap@acme.com>"
+ message.header['From'] = "=?utf-8?b?#{Base64::encode64(from).gsub("\n",'')}?= <#{config.default_email}>"
end
- message.header['To'] = "=?utf-8?b?#{Base64::encode64(from).gsub("\n",'')}?= <feed2imap@acme.com>"
+ message.header['To'] = "=?utf-8?b?#{Base64::encode64(from).gsub("\n",'')}?= <#{config.default_email}>"
if item.date.nil?
message.header['Date'] = Time::new.rfc2822
@@ -94,7 +94,7 @@ def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, w
# $2 contains url, $3 the image name, $4 the image extension
begin
image = Base64.encode64(HTTPFetcher::fetch($2, Time.at(0)).chomp) + "\n"
- cid = "#{Digest::MD5.hexdigest($2)}@feed2imap.acme.com"
+ cid = "#{Digest::MD5.hexdigest($2)}@#{config.hostname}"
if not cids.include?(cid)
cids << cid
imgpart = RMail::Message.new