------------------------------- The code for the contact form -------------------------------

------------------------------ In the base application file: ------------------------------ post '/' do configure_pony name = params[:name] sender_email = params[:email] message = params[:message] logger.error params.inspect begin Pony.mail( :from => "#{name}<#{sender_email}>", :to => 'example@gmail.com', :subject =>"#{name} has contacted you", :body => "#{message}", ) redirect '/success' rescue @exception = $! erb :boom end end def configure_pony Pony.options = { :via => :smtp, :via_options => { :address => 'smtp.sendgrid.net', :port => '587', :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :authentication => :plain, :enable_starttls_auto => true, :domain => 'heroku.com' } } end ------------- boom.erb is just a template that will show the exception message and the submitted params.