format string in email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
awelch
Forum Newbie
Posts: 3
Joined: Wed Nov 18, 2009 7:55 am

format string in email

Post by awelch »

Hi,

I have the message body of an email with the variable below:

$message = $customername."&nbsp".$customeraddress."<br/>".$telnumber."<br/>".$faxnumber."<br/>".$email."<br/>".$emailinv."<br/>".$autsig."<br/>".$position."<br/>".$date."</body>"."</html>";

I want to format the output so that each variable is printed on the next line but in my email I can see the markup outputted.

Sorry this is an incredibly simple thing to ask. It is my first post though so be gentle!

Andy
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: format string in email

Post by iankent »

If you're sending the email in plain text (which you are if you see <br /> instead of a newline), then simply replace all of the <br />'s with \n's, i.e.

Code: Select all

$message = $customername."&nbsp".$customeraddress."\n".$telnumber."\n".$faxnumber."\n".$email."\n".$emailinv."\n".$autsig."\n".$position."\n".$date;
hth
Post Reply