Sha256: fe18dd08fe9bddac991aadc7841efc7cb8ecb2f6d3af86973edd7238288c84b9

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.dirname(__FILE__)) + '/../lib/tuktuk'
require 'optparse'

def missing_keys?(opts)
  [:body, :from, :subject, :to] - opts.keys
end

options = {}

OptionParser.new do |opts|
  opts.banner = "Usage: tuktuk [options]"

  opts.on("-f", "--from your@email.com", String, "From email") do |val|
    options[:from] = val
  end

  opts.on("-t", "--to email1,email2", Array, "List of destination emails") do |list|
    options[:to] = list
  end

  opts.on("-s","--subject 'This is a test.'", String, "Email subject") do |subject|
    options[:subject] = subject
  end

  opts.on("-b", "--body 'Hello there.'", String, "Email body") do |body|
    options[:body] = body
  end

  opts.on_tail("-h", "--help", "Show this message") do
    puts opts
    exit
  end

  opts.on_tail("-v", "--version", "Show version") do
    puts Tuktuk::VERSION
    exit
  end

end.parse!

if list = missing_keys?(options) and list.any?
  puts "Missing option(s): #{list.join(', ')}"
  puts "Run with -h or --help for all options."
  exit
end

Tuktuk.options = {
  :max_workers => 0,
  :log_to => STDOUT
}

response, email = Tuktuk.deliver(options)

if response.is_a?(Tuktuk::Bounce)
  puts 'Email bounced. Type: ' + response.class.name # => HardBounce or SoftBounce
  puts response.message
else
  puts 'Email delivered!'
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tuktuk-0.9.0 bin/tuktuk
tuktuk-0.8.0 bin/tuktuk
tuktuk-0.7.1 bin/tuktuk
tuktuk-0.7.0 bin/tuktuk
tuktuk-0.6.5 bin/tuktuk
tuktuk-0.6.4 bin/tuktuk
tuktuk-0.6.3 bin/tuktuk
tuktuk-0.6.2 bin/tuktuk
tuktuk-0.6.1 bin/tuktuk