Page 1 of 1

Php mail help

Posted: Tue May 15, 2007 1:37 am
by ShaolinF
I have a php script which sends out an email over an action. The problem is, when I add hyperlinks, I cannot use "\n" to make new lines and therefore all the text comes out on one line.

Code: Select all

<?
$to = "Someone <yourname@mysite.com>"; 
$subject = "You recieved a message!";
$headers = "From: Mysite <mysite@mysite.com>\n";
$headers .= "MIME-Version: 1.0\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\n"; 
$headers .= "Reply-To: Mysite <mysite@mysite.com>\n"; 
$headers .= "X-Priority: 1\n"; 
$headers .= "X-MSmail-Priority: High\n"; 
$headers .= "X-mailer: My mailer"; 
//Content start
$message = "Thanks for your registration!\n";
$message = "___\n";
$message .= '<a href="http://www.mysite.com">www.mysite.com/editaccount.php?notifications</a>';
//Content end
mail ($to, $subject, $message, $headers) 
?>
I've tried the following code too but when I run the script all my text dissapears and only the link remains:

Code: Select all

$message = '<a href="http://www.myurl.com">Link</a>';

Posted: Tue May 15, 2007 2:06 am
by John Cartwright
pass your message through nl2br() or simply change your line breaks to <br> tags

Posted: Tue May 15, 2007 8:29 am
by feyd
The first two statements involving $message assignments are just that, assignments.