Jump to content


This topic is now archived and is closed to further replies.


Line breaks in Emails

Recommended Posts

I want to send a dynamic email, the only problem that I am having is that the line breaks won't work? Does anyone know how to put a line break in an email body? Here is my code:

$email = "someone@somewhere.com";
$subject = "Hey";
$body = "Dear Person,\nHow are you?";
echo "<a href=\"mailto:$email?subject=$subject&body=$body\">";

Everything is working except my email client isn't recognizing the line break (\n). I tried html (<br />) as well and that didn't work. Any help is appreciated.

Share this post

Link to post
Share on other sites
I tried that with no success. Here is the problem, since the string is enclosed by double quotes, it is interpreting the line breaks and carriage returns before it ever gets to the email client.  So I think I want literal characters (single quotes) to be sent to the email client. This still doesn't work though because it shows up as \n in my email client.  Thank you for your help.


Share this post

Link to post
Share on other sites
While the above should work no matter what app you are using to write code ... I have seen in some IDE 's where the IDE will insert it's own type of line break in your code.

Then it gets passed in your script without your knowledge.  The way you can test this is; open the script in your IDE and just put some IDE line spacing where you would want the line break.  If it works then you know what/where you problem is.

To fix it you'll need a different IDE or find the option in your IDE to turn off the auto line spacing.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.