1

I am using the ruby pony gem to send an automated email in my program. The problem is I cannot figure out how to give it a newline.

For example I give it,

    :body => 'first line\nsecond line' 

and that is what I get in the email is:

    first line\nsecond line

instead of

    first line
    second line

How can I fix this.

Richard
  • 239
  • 1
  • 3
  • 14

2 Answers2

1

Try with :body => "first line\nsecond line"

Single quotes ('') and double quotes ("") don't have the same meaning in ruby. Special characters (like \n or \t) are not interpreted with single quoted string.

Also you can't use string interpolation with them :

name = "John"
puts "My name is: #{name}" # output: "My name is John"
puts 'My name is: #{name}' # output: "My name is \#{name}"

You can take a look here.

Community
  • 1
  • 1
dgellow
  • 692
  • 1
  • 11
  • 18
0

The body of the email will probably take and send HTML tags. Have you tried inlining html? IE:

:body => "First Line <br /> Second Line"

will result in

First Line
Second Line
Momer
  • 3,158
  • 22
  • 23