I\'m new to all three, and I\'m trying to write a simple contact form for a website. The code I have come up with is below, but I know there are some fundamental problems with
In case anyone can use this, here is what you might need to use your gmail account to send mail.
post '/contact' do
require 'pony'
Pony.mail(
:name => params[:name],
:mail => params[:mail],
:body => params[:body],
:to => 'a_lumbee@gmail.com',
:subject => params[:name] + " has contacted you",
:body => params[:message],
:port => '587',
:via => :smtp,
:via_options => {
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'lumbee',
:password => 'p@55w0rd',
:authentication => :plain,
:domain => 'localhost.localdomain'
})
redirect '/success'
end
Note the redirect at the end, so you will need a success.haml to indicate to the user that their email was sent successfully.