# Line breaks removed from ActionMailer template

**URL:** <https://www.ruby-forum.com/t/line-breaks-removed-from-actionmailer-template/161468>\
**Category:** Rails\
**Created:** [February 26, 2009, 7:25pm UTC](https://www.ruby-forum.com/t/line-breaks-removed-from-actionmailer-template/161468 "2009-02-26T19:25:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phoenix\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5e9695/32.png) [@Phoenix\_R](https://www.ruby-forum.com/u/Phoenix_R)\
**Post date:** [February 26, 2009, 7:25pm UTC](https://www.ruby-forum.com/t/line-breaks-removed-from-actionmailer-template/161468/1 "2009-02-26T19:25:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Phoenix\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5e9695/32.png) [@Phoenix\_R](https://www.ruby-forum.com/u/Phoenix_R)\
**Post date:** [February 26, 2009, 7:35pm UTC](https://www.ruby-forum.com/t/line-breaks-removed-from-actionmailer-template/161468/2 "2009-02-26T19:35:32Z")

</div>

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
