Created
February 6, 2012 04:32
-
-
Save tomciopp/1749661 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 protected]"> | |
<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 => '[email protected]', | |
: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