-
Notifications
You must be signed in to change notification settings - Fork 0
/
personal.rb
66 lines (59 loc) · 1.25 KB
/
personal.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'rubygems'
require 'sinatra'
require 'pony'
require 'sinatra/content_for'
use Rack::Logger
helpers Sinatra::ContentFor
helpers do
def logger
request.logger
end
end
get '/' do
@page_title = "Welcome to tomciopp.com"
erb :index
end
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 => 'thomas.cioppettini@gmail.com',
:subject =>"#{name} has contacted you",
:body => "#{message}",
)
redirect '/success'
rescue
@exception = $!
erb :boom
end
end
get '/success' do
@page_title = "Email sent"
erb :success
end
get '/class' do
@page_title = "Agile web development class"
erb :class
end
get '/contact' do
erb :contact
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