Jump to content


Photo

Line breaks in Emails


  • Please log in to reply
3 replies to this topic

#1 Mateobus

Mateobus
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 27 September 2006 - 06:12 PM

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.

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 27 September 2006 - 06:23 PM

Try using "\r\n" instead of just "\n".

Ken

#3 Mateobus

Mateobus
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 27 September 2006 - 06:42 PM

Ken,
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.

Matt

#4 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 27 September 2006 - 06:45 PM

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.


Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users