class Minbox::Cli::Application

Public Instance Methods

send(host = 'localhost', port = 25) click to toggle source
# File lib/minbox/cli.rb, line 20
def send(host = 'localhost', port = 25)
  Net::SMTP.start(host, port) do |smtp|
    smtp.debug_output = Minbox.logger
    smtp.send_message(create_mail(options).to_s, options[:from], options[:to])
  end
end
server(host = 'localhost', port = '25') click to toggle source
# File lib/minbox/cli.rb, line 30
def server(host = 'localhost', port = '25')
  publisher = Publisher.from(options[:output])
  server = Server.new(host: host, port: port, tls: options[:tls])
  server.listen! do |mail|
    publisher.publish(mail)
  end
end
version() click to toggle source
# File lib/minbox/cli.rb, line 39
def version
  say Minbox::VERSION
end

Private Instance Methods

create_mail(options) click to toggle source
# File lib/minbox/cli.rb, line 45
def create_mail(options)
  Mail.new do |x|
    x.to = options[:to]
    x.from = options[:from]
    x.subject = options[:subject]
    x.body = STDIN.tty? ? options[:body] : $stdin.read
  end
end