aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/environment.rb38
1 files changed, 35 insertions, 3 deletions
diff --git a/config/environment.rb b/config/environment.rb
index ccf4c9ed6..a8f9bba95 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -71,13 +71,13 @@ end
# Validation error messages
ActiveRecord::Errors.default_error_messages[:blank] = "must be filled in"
-# Use SPAN instead of DIV. See http://dev.rubyonrails.org/ticket/2210
+# Monkeypatch! Use SPAN instead of DIV. See http://dev.rubyonrails.org/ticket/2210
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| %(<span class="fieldWithErrors">#{html_tag}</span>)}
# Include your application configuration below
-# Output HTML 4.0 compliant code, using method described in this ticket
-# http://dev.rubyonrails.org/ticket/6009
+# Monkeypatch! Output HTML 4.0 compliant code, using method described in this
+# ticket: http://dev.rubyonrails.org/ticket/6009
ActionView::Helpers::TagHelper.module_eval do
def tag(name, options = nil, open = false)
"<#{name}#{tag_options(options.stringify_keys) if options}>"
@@ -87,4 +87,36 @@ end
# Domain for URLs (so can work for scripts, not just web pages)
ActionController::UrlWriter.default_url_options[:host] = MySociety::Config.get("DOMAIN", 'localhost:3000')
+# Monkeypatch! Set envelope from in ActionMailer. Code mostly taken from this
+# Rails patch, with addition of using mail.from for sendmail if sender not set.
+# http://dev.rubyonrails.org/attachment/ticket/7697/action_mailer_base_sender.diff
+# Which is part of this ticket:
+# http://dev.rubyonrails.org/ticket/7697
+module ActionMailer
+ class Base
+ def perform_delivery_smtp(mail)
+ destinations = mail.destinations
+ sender = mail.sender(nil) || mail.from
+ mail.ready_to_send
+
+ Net::SMTP.start(smtp_settings[:address], smtp_settings[:port], smtp_settings[:domain],
+ smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp|
+ smtp.sendmail(mail.encoded, mail.from, destinations)
+ end
+ end
+
+ def perform_delivery_sendmail(mail)
+ sender = mail.sender(nil) || mail.from
+
+ arguments = sendmail_settings[:arguments].dup
+ arguments += " -f#{sender}"
+ IO.popen("#{sendmail_settings[:location]} #{arguments}","w+") do |sm|
+ sm.print(mail.encoded.gsub(/\r/, ''))
+ sm.flush
+ end
+ end
+ end
+end
+
+