Forum: Ruby on Rails Line breaks removed from ActionMailer template

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Phoenix R. (Guest)
on 2009-02-26 20:25
(Received via mailing list)
I've been googling and searching this list for about an hour now, and
maybe I'm just not thinking of the common nomenclature for what to be
looking for, but I can't find jack.

Here's the deal:  I've got an application coded correctly, sending the
mail out, and the template is structured correctly (method_name.erb is
the filename) with LF line breaks (have also tried CRLF and CR, same
effect) and all.

Unfortunately, any time the e-mail is received, all the line breaks
are removed.  The e-mail is being sent as plain text, in UTF-8 - the

For example:

Line one
line two


Line oneline two

Looking at development.log, it shows that the line breaks are there.
Indeed, of course my template has line breaks in it, separating lines
and paragraphs.

I'm on OS X 10.5.6, using sendmail.  Settings inside config/
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = { :location => '/usr/sbin/
sendmail', :arguments => '-i -t'}
config.action_mailer.perform_deliveries = true

I'm writing the template in TextMate and have tried all three line-
ending types:

I've even tried via SMTP on another server, and have had the exact
same results.

I've thought of just going straight to HTML e-mail and formatting it
using <p> and other tags, but the problem with that is that I don't
want this ending up in spam boxes due to over-aggressive filtering.
Plus, there's really no reason this needs to be in HTML - plain text
should be fine.

Does anyone have any clues as to what could be causing this issue?

Thanks for your help.
Phoenix R. (Guest)
on 2009-02-26 20:35
(Received via mailing list)
I'm an idiot who had a typo in his code.  I had set content_type in
the ActionMailer-inherited method to text/html on accident.  For

class Foo < ActionMailer::Base

def bar(to, info)
  recipients to
  from "removed_email_address@domain.invalid"
  subject "FooBar"
  body :info => info
  content type 'text/html' # THIS WAS THE PROBLEM! - should have been
This topic is locked and can not be replied to.