class FormProcessor::Mailer
Sends an email with form results to the address specified in “mailto”. A valid SMTP server running on localhost is required.
Public Class Methods
new(values,output)
click to toggle source
Expects a Hash value and String for the email body passed from Main
.
# File lib/mailer.rb, line 6 def initialize(values,output) @values = values @output = output run end
Private Instance Methods
run()
click to toggle source
# File lib/mailer.rb, line 12 def run msg = <<END_OF_MESSAGE From: Automated Form Mailer <#{@values['mailto']}> To: <#{@values['mailto']}> Content-type: text/html Subject: #{@values['subject']} #{@output} END_OF_MESSAGE Net::SMTP.start('localhost') do |smtp| smtp.send_message(msg,@values['mailto'],@values['mailto']) smtp.finish end end