Class: Maildis::CLI
- Inherits:
-
Thor
- Object
- Thor
- Maildis::CLI
- Defined in:
- lib/maildis.rb
Constant Summary collapse
- @@log_file_name =
Dir.home + '/.maildis.log'
Instance Method Summary collapse
Instance Method Details
#dispatch(mailer_path) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/maildis.rb', line 45 def dispatch(mailer_path) init_logger [:verbose] begin config = load_config mailer_path recipients = load_recipients config['mailer']['recipients'] info "Dispatching to #{recipients.size} recipients" result = Dispatcher.dispatch({subject: config['mailer']['subject'], recipients: recipients, sender: load_sender(config['mailer']['sender']), templates: load_templates(config['mailer']['templates']), server: load_server(config['smtp']), logger: @@logger}) info "Dispatch complete with errors" if result[:not_sent].size > 0 info "Dispatch complete without errors" if result[:not_sent].size == 0 exit rescue => e fatal e. end end |
#ping(mailer_path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/maildis.rb', line 30 def ping(mailer_path) init_logger [:verbose] begin config = load_config mailer_path $stdout.puts "SMTP server reachable" if ServerUtils.server_reachable? config['smtp']['host'], config['smtp']['port'] exit rescue ValidationError => e error "Validation Error: #{e.}" rescue => e fatal "Error: #{e.}" end end |
#validate(mailer_path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/maildis.rb', line 14 def validate(mailer_path) init_logger [:verbose] begin raise ValidationError, "File not found: #{mailer_path}" unless File.exists?(File.(mailer_path)) load_config mailer_path $stdout.puts 'Ok' exit rescue ValidationError => e error "Validation Error: #{e.}" rescue => e fatal "Error: #{e.}" end end |