wright67uk Posted February 8, 2011 Share Posted February 8, 2011 The code below returns the correct results, which are in this case are email addresses. After each displayed value there is a br eg. emai1@hotmail.com<br>email2@hotmail.com<br>email3@ etc. So the quesion is, can i change the below codeing to prevent this. I have tried changing $message .= "<br>". $row['email'] to $message .= "\n". $row['email'] but this results in; Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html so now i changed the line to $message .= "\r\n". $row['email'] and my email displays perfectly. The only problem now is that the email addresses and message are all on one line on screen, is there a way to get each of the returned email addresses to sit on a new line, without it bringing back those br br br's in my email output? mysql_select_db("treesurgery") or die("Unable to select database"); $code = $_GET['postcode']; $message = $_GET['message']; $emailad = "email@hotmail.co.uk"; $shortcode = substr($code,0,2); $result = mysql_query("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3") or die(mysql_error()); echo "<h2>Business Names:</h2>"; while ($row = mysql_fetch_array( $result )) { $message .= "\r\n". $row['email'] ; } echo $message; mail( "$emailad", "Header","$message" ); echo "<br>" . "Thank you for using our mail form."; Thankyou Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Share Posted February 8, 2011 Surely you can just use the <p> tag? Quote Link to comment Share on other sites More sharing options...
wright67uk Posted February 8, 2011 Author Share Posted February 8, 2011 The only thing with that is that instead of <br> following each row in my email, it would be <p> instead Quote Link to comment Share on other sites More sharing options...
wright67uk Posted February 9, 2011 Author Share Posted February 9, 2011 changing; echo $message; to echo nl2br $message; seemed to clear this one up Quote Link to comment 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.