2012-07-20 17:06:31 +01:00
|
|
|
class FeedbackMailer < ActionMailer::Base
|
|
|
|
FBM_CONFIG = APP_CONFIG['feedback']
|
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
default to: FBM_CONFIG['email'],
|
|
|
|
cc: FBM_CONFIG['cc'],
|
|
|
|
bcc: FBM_CONFIG['bcc']
|
|
|
|
default_url_options.merge!(protocol: 'https') if APP_CONFIG['mailer_https_url']
|
2012-07-20 17:06:31 +01:00
|
|
|
|
2016-05-28 19:21:02 +01:00
|
|
|
# include Resque::Mailer # send email async
|
2012-07-20 17:06:31 +01:00
|
|
|
|
|
|
|
def feedback_form_send(form_data)
|
|
|
|
@data = Feedback.new(form_data)
|
|
|
|
|
|
|
|
from = "#{@data.name} <#{@data.email}>"
|
|
|
|
subj = prepare_subject(@data.subject)
|
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
mail from: from, subject: subj
|
2012-07-20 17:06:31 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def prepare_subject(subject)
|
|
|
|
res = ''
|
|
|
|
res << affix(FBM_CONFIG['subject_prefixes'])
|
|
|
|
res << subject
|
|
|
|
res << affix(FBM_CONFIG['subject_postfixes'])
|
2012-07-20 20:59:32 +01:00
|
|
|
res = res.strip.gsub(/\s+/, ' ')
|
2012-07-20 17:06:31 +01:00
|
|
|
res
|
|
|
|
end
|
|
|
|
|
|
|
|
def affix(affixes)
|
2012-07-20 20:59:32 +01:00
|
|
|
' %s ' % Array(affixes).map{|e| "[#{e}]"}.join
|
2012-07-20 17:06:31 +01:00
|
|
|
end
|
|
|
|
end
|