Skip to content

Instantly share code, notes, and snippets.

@tomciopp
Created February 6, 2012 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomciopp/1749661 to your computer and use it in GitHub Desktop.
Save tomciopp/1749661 to your computer and use it in GitHub Desktop.
the contact form
=========================================================
<div id='contact-box' class="group">
<div class="span6 clear">
<form action="/contact" method="post" class="well">
<label for="name">Your Name:</label>
<input type="text" class="span4" placeholder="John Smith...">
<label for="email">Your email address:</label>
<input type="email" class="span4" placeholder="email@example.com">
<label for="to">Your message:</label>
<textarea name="message" cols='30' rows="10"></textarea><br>
<button type="submit" class="btn" value="Send">Submit</button>
</form>
</div>
</div>
=========================================================
the app.rb file
post '/contact' do
name = params[:name]
sender_email = params[:email]
message = params[:message]
Pony.mail(
:from => "#{name} <#{sender_email}>",
:to => 'thomas.cioppettini@gmail.com',
:subject =>"#{name} has contacted you",
:body => "#{message}",
:port => '587',
:via => :smtp,
:via_options => {
:address => 'smtp.sendgrid.net',
:port => '587',
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:authentication => :plain,
:enable_starttls_auto => true
})
redirect '/success'
end
get '/success' do
@page_title = "Email sent"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment