Solved

PHP e-mail question?

Posted on 2004-09-06
4
201 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:
Squinky 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:Squinky
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now