Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP e-mail question?

Posted on 2004-09-06
4
Medium Priority
?
211 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:Umesh
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 200 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:Umesh
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 dynamically set the form action using jQuery.
Suggested Courses

916 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