Nodemailer: Problem with line break in "body:"

Created on 24 Aug 2011  ·  3Comments  ·  Source: nodemailer/nodemailer

If you try to send a message with line breaks

"Hello!

How are you!?

Cheers!"

Occour an error!

The same message:

"Hello! \n\nHow are you!?\n\nCheers!"

Its ok!

Can you fix it!? Thanks!

Most helpful comment

Hi,

are you trying to set the linebreaks in your code like this?

{
    from: "[email protected]",
    to: "[email protected]",
    subject: "test mail",

    text: "Hello!

How are you!?

Cheers!"
}

This doesn't work since JavaScript doesn't support multi-line strings, you need to go with \n symbols.

{
    from: "[email protected]",
    to: "[email protected]",
    subject: "test mail",

    text: "Hello!\n\nHow are you!?\n\nCheers!"
}

All 3 comments

Hi,

are you trying to set the linebreaks in your code like this?

{
    from: "[email protected]",
    to: "[email protected]",
    subject: "test mail",

    text: "Hello!

How are you!?

Cheers!"
}

This doesn't work since JavaScript doesn't support multi-line strings, you need to go with \n symbols.

{
    from: "[email protected]",
    to: "[email protected]",
    subject: "test mail",

    text: "Hello!\n\nHow are you!?\n\nCheers!"
}

Oh! :( Well, its a form to pass an html file like this:

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            body, p {
                margin:0px;
                padding: 0px;
            }
        </style>
    </head>
    <body>
        <p>Olá! Isso é um teste!</p>
    </body>
</html>

and here to it:

{
    from: "[email protected]",
    to: "[email protected]",
    subject: "test mail",

    htmlFile: "myEmailMkt.html"
}

Thanks!

I don't think this is a Nodemailer issue. You should check the input from the file you are reading since Nodemailer doesn't touch line endings at all - it simply passes everything entered to to the server

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdevDE picture mdevDE  ·  13Comments

Meenakshi14 picture Meenakshi14  ·  13Comments

higunjan picture higunjan  ·  22Comments

dcbartlett picture dcbartlett  ·  10Comments

hippich picture hippich  ·  21Comments