Last active
May 25, 2021 15:47
-
-
Save fullstackplus/d035be3fc360cac7800e400cd28c5beb to your computer and use it in GitHub Desktop.
This file contains 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
post '/contact' do | |
configure_options | |
Pony.mail( | |
:from => [params[:name], "<", params[:email], ">"].join, | |
:to => '[email protected]', | |
: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