diff --git a/actionpack/lib/action_view/template_handlers/builder.rb b/actionpack/lib/action_view/template_handlers/builder.rb
index <HASH>..<HASH> 100644
--- a/actionpack/lib/action_view/template_handlers/builder.rb
+++ b/actionpack/lib/action_view/template_handlers/builder.rb
@@ -6,7 +6,8 @@ module ActionView
       include Compilable
 
       def compile(template)
-        "controller.response.content_type ||= Mime::XML;" +
+        # ActionMailer does not have a response
+        "controller.respond_to?(:response) && controller.response.content_type ||= Mime::XML;" +
           "xml = ::Builder::XmlMarkup.new(:indent => 2);" +
           template.source +
           ";xml.target!;"
Check for response in builder template since ActionMailer does not have one