Solved

PHP e-mail question?

Posted on 2004-09-06
4
203 Views
Last Modified: 2006-11-17
I want to send a multilane email that is generated from variables I collect on another page.

I am using:

$text = 'WEB INFO REQUEST 'BY '.$name . 'PRODUCT: '.$prod. ' ID CODE: '.$id_code.'******** END OF E-MAIL *********';

mail('xxxxxxx@yahoo.com','WEB INFO REQUEST',$text,"From: $name <$email>");

I want to separate this content on new lines?

Thanks
0
Comment
Question by:bliesveld
  • 2
  • 2
4 Comments
 
LVL 26

Expert Comment

by:ushastry
ID: 11994169
try this..

$text = '\n WEB INFO REQUEST 'BY '.$name . '\n PRODUCT: '.$prod. ' \nID CODE: '.$id_code.'\n******** END OF E-MAIL *********';


check out here for more..
http://us2.php.net/function.mail
0
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 50 total points
ID: 11995030
ushastry is right - you just need line breaks. I'd still recommend that you use PHPMailer (phpmailer.sourceforge.net). It's a whole load easier and more reliable than mail() alone.
0
 
LVL 26

Expert Comment

by:ushastry
ID: 11995057

yeah am agree with Squinky , it is better if you go for phpmailer.sourceforge.net.
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 11995117
I just spotted a problem with ushastry's example - it's using single quotes, so escaped chars won't get interpolated, i.e. \n will not be converted to a newline. Using double quotes, you can also put vars within the string anyway:

$text = "\nWEB INFO REQUEST BY $name\nPRODUCT: $prod\nID CODE: $id_code\n******** END OF E-MAIL *********";

I think that for ugly historical reasons, emails are meant to use CRLF DOS-style line breaks. PHPMailer deals with all that for you though.

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question