Skip to content

Instantly share code, notes, and snippets.

@fullstackplus
Last active May 25, 2021 15:47
Show Gist options
  • Save fullstackplus/d035be3fc360cac7800e400cd28c5beb to your computer and use it in GitHub Desktop.
Save fullstackplus/d035be3fc360cac7800e400cd28c5beb to your computer and use it in GitHub Desktop.
post '/contact' do
configure_options
Pony.mail(
:from => [params[:name], "<", params[:email], ">"].join,
:to => 'hi@mydomain.com',
:subject => ["Opt-in via /contact: ", params[:name]].join,
:body => [params[:name], params[:email]].join(": ")
)
redirect '/'
end
def configure_options
Pony.options = {
:via => :smtp,
:via_options => {
:address => 'smtp.sendgrid.net',
:port => '587',
:domain => 'heroku.com',
:user_name => ENV.fetch('SENDGRID_USERNAME'),
:password => ENV.fetch('SENDGRID_USERNAME'),
:authentication => :plain,
:enable_starttls_auto => true
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment