module JamRuby
  # CorpMail must be configured to work
  # Some common configs occur in jam_ruby/init.rb
  # Environment specific configs occur in spec_helper.rb in jam-ruby and jam-web (to put it into test mode),
  # and in config/initializers/email.rb in rails to configure sendmail account settings
  # If UserMailer were to be used in another project, it would need to be configured there, as well.

  # Templates for UserMailer can be found in jam_ruby/app/views/jam_ruby/user_mailer
  class CorpMailer < ActionMailer::Base
    include SendGrid

    layout "user_mailer"

    DEFAULT_SENDER = "noreply@jamkazam.com"

    default :from => DEFAULT_SENDER

    sendgrid_category :use_subject_lines
    #sendgrid_enable   :opentrack, :clicktrack  # this makes our emails creepy, imo (seth)
    sendgrid_unique_args :env => Environment.mode

    def feedback(feedback)
      @email = feedback.email
      @body = feedback.body

      sendgrid_category "Corporate"
      sendgrid_unique_args :type => "feedback"

      mail(:to => "info@jamkazam.com", :subject => "Feedback received from #{@email} ") do |format|
        format.text
        format.html
      end
    end
  end
end
