Skip to content

Instantly share code, notes, and snippets.

@desbest
Created October 21, 2012 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save desbest/cc6b728e6c9832f8cf83 to your computer and use it in GitHub Desktop.
Save desbest/cc6b728e6c9832f8cf83 to your computer and use it in GitHub Desktop.
def feedback
if request.post? #this line is potentially dangerous!
data = request.subset(:message, :email, :email2, :technical) #data = request.xxx
#return data
@email = data.fetch("email"); @email2 = data.fetch("email2"); @message = data.fetch("message"); @technical = data.fetch("technical"); @username = user.username; if !@username then @username = "anonymous" end
@emailcontent = "Compesh feedback from <span style='font-weight: bold; color: #0066cc; font-size: 1.15em;'>#{@username}</span><br><br> <b>email: </b>#{@email}<br> <b>email2: </b>#{@email2}<br> <b>message: </b>#{@message}<br> <b>technical: </b>#{@technical}\n"
begin
Pony.mail(:html_body => @emailcontent, :reply_to => @email, :subject => "Compesh Feedback from #{@username}", :headers => { "X-MC-Tags" => "feedback" } )
flash[:success] = 'Your email has been sent!'
redirect 'feedback'
rescue => e
logger = Ramaze::Logger::RotatingInformer.new('./log')
logger.error "Error emailing feedback. #{e}" #Ramaze::Log.error(e)
flash[:error] = 'Failure sending email. Contact technical support!'
redirect 'feedback' #redirect_referrer
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment