Line breaks removed from ActionMailer template


#1

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

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.


#2

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 “removed_email_address@domain.invalid”
subject “FooBar”
sent_on Time.now
body :info => info
content type ‘text/html’ # THIS WAS THE PROBLEM! - should have been
‘text/plain’
end
end