Newline in PHP email

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Joined: Aug 04, 2008
  • Posts: 846
  • Status: Offline

Post January 24th, 2013, 4:23 pm

I've tried everything I can personally think of to create a new line in my email being sent from php. "\n", "\r", "<br>" all end up being part of the email text rather than new lines. Anyone know what the issue is? Here's the part of the script that sends the message:


PHP Code: [ Select ]
   $message = '';
   foreach($inputs as $val)
      $message .= '\n' . $val;
   if(mail($this->to, $inputs['subject'], $message) )
      echo 'Thank you, I\'ll get back to you real soon!';
 
  1.    $message = '';
  2.    foreach($inputs as $val)
  3.       $message .= '\n' . $val;
  4.    if(mail($this->to, $inputs['subject'], $message) )
  5.       echo 'Thank you, I\'ll get back to you real soon!';
  6.  
Use your words like arrows to shoot toward your goal.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 24th, 2013, 4:23 pm

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Joined: Aug 04, 2008
  • Posts: 846
  • Status: Offline

Post January 24th, 2013, 4:29 pm

Nevermind...I just figured it out. It's because I was using single quotes rather than double quotes in my foreach statement.

Why is it I get stuck on something for 2 days, and then post here and figure it out in seconds? I should post on here more often hahaha.
Use your words like arrows to shoot toward your goal.
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post January 24th, 2013, 10:32 pm

I learn quicker under public scrutiny too. I think the pressure of looking like a moron makes us forget the distracting elements of our lives and focus on the task at hand. :)
Strong with this one, the sudo is.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6128
  • Loc: Seattle, WA
  • Status: Offline

Post January 25th, 2013, 4:48 pm

Also, it's a pretty common thing for people to find their own bugs when explaining a problem to others. Much of it is because when you're examining your own code, you're operating with a bunch of assumptions that cause you to overlook or miss things. When you need to explain something to someone else, you drop the assumptions and end up seeing the issue yourself.
The Beer Monocle. Classy.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Joined: Aug 04, 2008
  • Posts: 846
  • Status: Offline

Post January 29th, 2013, 4:15 pm

Totally agree spork - unfortunately the rubber ducky debugging method hasn't worked for me. Apparently needs to be a real person for some reason. Even someone who has absolutely no idea what I'm talking about. Seems to work well for me nearly every time.
Use your words like arrows to shoot toward your goal.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 211 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.