Module: Tuktuk

Defined in:
lib/tuktuk/dns.rb,
lib/tuktuk/cache.rb,
lib/tuktuk/rails.rb,
lib/tuktuk/bounce.rb,
lib/tuktuk/tuktuk.rb,
lib/tuktuk/version.rb,
lib/tuktuk/package.rb,
lib/tuktuk/tuktuk.rb

Defined Under Namespace

Modules: DNS, Package Classes: Bounce, Cache, HardBounce, SoftBounce

Constant Summary collapse

MAJOR =
0
MINOR =
8
PATCH =
0
VERSION =
[MAJOR, MINOR, PATCH].join('.')

Class Method Summary collapse

Class Method Details

.cacheObject



37
38
39
# File 'lib/tuktuk/tuktuk.rb', line 37

def cache
  @cache ||= Cache.new(100)
end

.deliver(message, opts = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/tuktuk/tuktuk.rb', line 41

def deliver(message, opts = {})
  # raise 'Please pass a valid message object.' unless message[:to]
  bcc = opts.delete(:bcc) || []
  bcc = [bcc] if bcc.is_a?(String)

  self.options = opts if opts.any?
  mail = Package.build(message)
  response = lookup_and_deliver(mail, bcc)
  return response, mail
end

.deliver!(mail, opts = {}) ⇒ Object

same as deliver but raises error. used by ActionMailer



53
54
55
56
57
58
59
60
61
# File 'lib/tuktuk/tuktuk.rb', line 53

def deliver!(mail, opts = {})
  @logger = Rails.logger if defined?(Rails) and !config[:log_to]
  resp, email = deliver(mail, opts)
  if resp.is_a?(Exception)
    raise resp
  else
    return resp, email
  end
end

.deliver_many(messages, opts = {}) ⇒ Object

Raises:

  • (ArgumentError)


63
64
65
66
67
68
# File 'lib/tuktuk/tuktuk.rb', line 63

def deliver_many(messages, opts = {})
  raise ArgumentError, "Not an array of messages: #{messages.inspect}" unless messages.any?
  self.options = opts if opts.any?
  messages_by_domain = reorder_by_domain(messages)
  lookup_and_deliver_many(messages_by_domain)
end

.dkim=(dkim_opts) ⇒ Object



77
78
79
80
81
# File 'lib/tuktuk/tuktuk.rb', line 77

def dkim=(dkim_opts)
  Dkim::domain      = dkim_opts[:domain]
  Dkim::selector    = dkim_opts[:selector]
  Dkim::private_key = dkim_opts[:private_key]
end

.new(options) ⇒ Object



7
8
9
10
# File 'lib/tuktuk/rails.rb', line 7

def self.new(options)
  self.options = options
  self
end

.options=(hash) ⇒ Object



70
71
72
73
74
75
# File 'lib/tuktuk/tuktuk.rb', line 70

def options=(hash)
  if dkim_opts = hash.delete(:dkim)
    self.dkim = dkim_opts
  end
  config.merge!(hash)
end