FredFogg Posted May 3, 2010 Share Posted May 3, 2010 I am using php to send a text email and I am populating the message and I have tried a couple examples I found on the internet, but it isn't working. It is a simple email, so no need to send in html format. Here is what I have $email_msg = 'Email : ' . $Email; $email_msg .= '\n' .'First Name : ' . $FirstName; $email_msg .= '\n' . 'Last Name : ' . $LastName; and the email I am getting Email : johnsmith@live.com\nFirst Name : john\nLast Name : smith what I want is Email : johnsmith@live.com First Name : john Last Name : smith What am I doing wrong or do I need to add something to the header? Quote Link to comment https://forums.phpfreaks.com/topic/200513-formatting-email-message-in-php/ Share on other sites More sharing options...
premiso Posted May 3, 2010 Share Posted May 3, 2010 $email_msg = 'Email : ' . $Email; $email_msg .= "\n" .'First Name : ' . $FirstName; $email_msg .= "\n" . 'Last Name : ' . $LastName; ' take the \n character literally. You need to encase it in double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/200513-formatting-email-message-in-php/#findComment-1052203 Share on other sites More sharing options...
FredFogg Posted May 3, 2010 Author Share Posted May 3, 2010 I changed it to double quotes and this is what I got Parse error: syntax error, unexpected T_STRING in /mnt/w0712/d04/s31/b0301c6a/www.blah.com/members/omrSendEmail.php on line 88 Quote Link to comment https://forums.phpfreaks.com/topic/200513-formatting-email-message-in-php/#findComment-1052204 Share on other sites More sharing options...
FredFogg Posted May 3, 2010 Author Share Posted May 3, 2010 Ok, that fixed the formatting, but caused my variables not to print: $email_msg = 'Email : ' . $Email; $email_msg .= "\n" . 'First Name : ' . $FirstName; $email_msg .= "\n" . 'Last Name : ' . $LastName; results in: Email : First Name : Last Name : Quote Link to comment https://forums.phpfreaks.com/topic/200513-formatting-email-message-in-php/#findComment-1052207 Share on other sites More sharing options...
FredFogg Posted May 3, 2010 Author Share Posted May 3, 2010 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/200513-formatting-email-message-in-php/#findComment-1052244 Share on other sites More sharing options...
premiso Posted May 3, 2010 Share Posted May 3, 2010 Where is the firstname / email defined? The changes I mentioned should not have broke the rest of the script at all. Quote Link to comment https://forums.phpfreaks.com/topic/200513-formatting-email-message-in-php/#findComment-1052411 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.