require 'bundler/setup' require 'snails' require 'snails/mailer' class MyApp < Snails::App set :session_secret, SecureRandom.hex(32) # generates a new session cookie on each login register Snails::Assets register Snails::Sessions # register Snails::Database get '/' do number = session[:number] || 0 session[:number] = number.to_i + 1 "

Hello world!

This is your visit number #{number}. Come again!

" end end Notifier = Snails::Mailer.new({ from: 'User ', smtp: { helo_domain: 'myapp.com' } }) Notifier.email(:new_message) do |message| text = "You have a new message from: #{message.from.email}" send_email(to: message.to.email, subject: "New message!", body: text) end