class Stubby::Extensions::SMTP::Server

Public Instance Methods

expand_rule(trigger, instruction) click to toggle source
# File lib/stubby/extensions/smtp.rb, line 37
def expand_rule(trigger, instruction)
  {
    "#{trigger.gsub("smtp://", "dns://")}/mx" => "dns-mx://#{STUBBY_MASTER}/?priority=10"
  }
end
restore!() click to toggle source
# File lib/stubby/extensions/smtp.rb, line 47
def restore!
  # nil
end
run!(session, options) click to toggle source
# File lib/stubby/extensions/smtp.rb, line 7
def run!(session, options)
  @process = Process.fork {
    $0 = "stubby: [extension worker sub] Stubby::Extensions::SMTP::Server"

    sleep 2

    HTTPI.post("http://#{STUBBY_MASTER}:9000/stubs/transient/activate.json",
      options: MultiJson.dump(smtp_stub), key: "_smtp")
    
    MailCatcher.run! smtp_ip: STUBBY_MASTER,
      smtp_port: 25,
      http_ip: STUBBY_MASTER,
      http_port: 9001,
      daemon: false
  }

  trap("INT", important: true){
    stop!
  }

  sleep
end
smtp_stub() click to toggle source
# File lib/stubby/extensions/smtp.rb, line 30
def smtp_stub
  {
    "dns://outbox.stubby.dev/a" => "dns-a://#{STUBBY_MASTER}",
    "http://outbox.stubby.dev" => "http://#{STUBBY_MASTER}:9001"
  }
end
stop!() click to toggle source
# File lib/stubby/extensions/smtp.rb, line 43
def stop!
  Process.shutdown(@process)
end