forked from flores/myway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.rb
51 lines (41 loc) · 825 Bytes
/
contact.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
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'erb'
require 'sanitize'
require 'aws/ses'
set :environment, :production
set :port, '4000'
#set :bind, 'localhost'
EMAIL = '[email protected]'
get '/' do
erb :impress
end
get '/title/:newtitle' do
@newtitle = params[:newtitle]
erb :impress
end
get '/contact' do
erb :contact
end
post '/contact' do
params.collect! do |param|
Sanitize.clean(param)
end
ses = AWS::SES::Base.new(
:access_key_id => 'id',
:secret_access_key => 'key'
)
ses.send_email(
:to => EMAIL,
:from => EMAIL,
:subject => params[:mail] + " sent you a message",
:body => "subject: " + params[:subject] + "\nname: " +
params[:name] + "\n\n" + params[:body]
)
@name = params[:name]
erb :success
end
error do
erb :error
end