Forum: Ruby on Rails Line breaks removed from ActionMailer template

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ef2b8b885f5aa34581fb2b12549c7f9e?d=identicon&s=25 Phoenix Rising (Guest)
on 2009-02-26 19: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
defaults.

For example:

Line one
line two

Becomes:

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/
environments/develpment.rb:
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:
LF
CRLF
CR

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.
Ef2b8b885f5aa34581fb2b12549c7f9e?d=identicon&s=25 Phoenix Rising (Guest)
on 2009-02-26 19:35
(Received via mailing list)
IGNORE THE ABOVE.
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
example:

class Foo < ActionMailer::Base

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