diff options
-rw-r--r-- | app/helpers/application_helper.rb | 3 | ||||
-rw-r--r-- | app/helpers/mailer_helper.rb | 7 | ||||
-rw-r--r-- | app/models/application_mailer.rb | 7 | ||||
-rw-r--r-- | app/models/track_mailer.rb | 6 |
4 files changed, 11 insertions, 12 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0520a8c77..df016a249 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -17,6 +17,9 @@ module ApplicationHelper # Site-wide access to configuration settings include ConfigHelper + # Useful for sending emails + include MailerHelper + # Copied from error_messages_for in active_record_helper.rb def foi_error_messages_for(*params) options = params.last.is_a?(Hash) ? params.pop.symbolize_keys : {} diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb new file mode 100644 index 000000000..fe7de0edc --- /dev/null +++ b/app/helpers/mailer_helper.rb @@ -0,0 +1,7 @@ +module MailerHelper + def contact_from_name_and_email + contact_name = MySociety::Config.get("TRACK_SENDER_NAME", 'Alaveteli') + contact_email = MySociety::Config.get("TRACK_SENDER_EMAIL", 'contact@localhost') + return "#{contact_name} <#{contact_email}>" + end +end diff --git a/app/models/application_mailer.rb b/app/models/application_mailer.rb index 80f0d7289..044006f7c 100644 --- a/app/models/application_mailer.rb +++ b/app/models/application_mailer.rb @@ -9,17 +9,12 @@ class ApplicationMailer < ActionMailer::Base # Include all the functions views get, as emails call similar things. helper :application + include MailerHelper # This really should be the default - otherwise you lose any information # about the errors, and have to do error checking on return codes. self.raise_delivery_errors = true - def contact_from_name_and_email - contact_name = MySociety::Config.get("CONTACT_NAME", 'Alaveteli') - contact_email = MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') - return "#{contact_name} <#{contact_email}>" - end - def blackhole_email MySociety::Config.get("BLACKHOLE_PREFIX", 'do-not-reply-to-this-address')+"@"+MySociety::Config.get("INCOMING_EMAIL_DOMAIN", "localhost") end diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb index f618fba49..d3abd0489 100644 --- a/app/models/track_mailer.rb +++ b/app/models/track_mailer.rb @@ -26,12 +26,6 @@ class TrackMailer < ApplicationMailer @body = { :user => user, :email_about_things => email_about_things, :unsubscribe_url => unsubscribe_url } end - def contact_from_name_and_email - contact_name = MySociety::Config.get("TRACK_SENDER_NAME", 'Alaveteli') - contact_email = MySociety::Config.get("TRACK_SENDER_EMAIL", 'contact@localhost') - return "#{contact_name} <#{contact_email}>" - end - # Send email alerts for tracked things. Never more than one email # a day, nor about events which are more than a week old, nor # events about which emails have been sent within the last two |