rsammy Posted April 30, 2007 Share Posted April 30, 2007 i am working on an e-mail system within myapplication. i need to add this line "PLEASE DO NOT REPLY TO THIS EMAIL AS THIS IS AN UNATTENDED, AUTO GENERATED EMAIL. " after a line of text within the message body. how do i insert thsi line on a new line with a line break? heres my code: $message = $name." has sent a message to you through InstiComm's message center. In order to get this message follow this link ".$varurlMC . "PLEASE DO NOT REPLY TO THIS EMAIL AS THIS IS AN UNATTENDED, AUTO GENERATED EMAIL. "; mail($to, "New InstiComm.com Mail From: ".$name, $message, $headers); i would like to display this text(PLEASE DO NOT REPLY...GENERATED EMAIL on a new line(with a line break in between). also, how do i just append this text on a new line to '$message'. is it possible for me to move this text to a variable say, '$noreply' and then concatenate it with '$message' but, starting on a new line? thanx Link to comment https://forums.phpfreaks.com/topic/49337-solved-line-break-in-php/ Share on other sites More sharing options...
The Little Guy Posted April 30, 2007 Share Posted April 30, 2007 <? $message = $name." has sent a message to you through InstiComm's message center. In order to get this message follow this link ".$varurlMC . " <p> PLEASE DO NOT REPLY TO THIS EMAIL AS THIS IS AN UNATTENDED, AUTO GENERATED EMAIL. </p>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, "New InstiComm.com Mail From: ".$name, $message, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/49337-solved-line-break-in-php/#findComment-241766 Share on other sites More sharing options...
rsammy Posted April 30, 2007 Author Share Posted April 30, 2007 thanx for replying, little guy! it kinda works. but, he <p> and </p> tags appear in the email body! how do i prevent them? Link to comment https://forums.phpfreaks.com/topic/49337-solved-line-break-in-php/#findComment-241777 Share on other sites More sharing options...
The Little Guy Posted April 30, 2007 Share Posted April 30, 2007 did you add the headers I put in the code? Link to comment https://forums.phpfreaks.com/topic/49337-solved-line-break-in-php/#findComment-241811 Share on other sites More sharing options...
rsammy Posted April 30, 2007 Author Share Posted April 30, 2007 sorry, this is my original code. now how do i do this? $query = "INSERT INTO messages (message,user_id,status,subject,from_p,received,to_email,time_sent) VALUES ('$message_x','$userid','1','$subject','$user_email','$DATE','$to','$TIME')"; $resultquery= mysql_query($query); $sentmsg_ID = mysql_insert_id(); //print ($sentmsg_ID); $sentquery = "INSERT INTO sent_messages (user_id, message_id) VALUES ('$userid', '$sentmsg_ID')"; $resultsent=mysql_query($sentquery); $id = mysql_insert_id(); $headers .= "From: $name <$user_email>\n"; $headers .= "X-Sender: <$user_email>\n"; $headers .= "X-Mailer: PHP\n"; // mailer $headers .= "X-Priority: 1\n"; // Urgent message! $headers .= "Return-Path: <$varreturnpath>\n"; // Return path for errors $message = $name." has sent a message to you through InstiComm's message center. In order to get this message follow this link ".$varurlMC ." PLEASE DO NOT REPLY TO THIS EMAIL AS THIS IS AN UNATTENDED, AUTO GENERATED EMAIL."; mail($to, "New Insticomm.com Mail From: ".$name, $message, $headers); header("Location: main.php?m1=".$_POST["m1"]."&d1=".$_POST["d1"]."&y1=".$_POST["y1"]."&m2=".$_POST["m2"]."&d2=".$_POST["d2"]."&y2=".$_POST["y2"]); exit; thanx Link to comment https://forums.phpfreaks.com/topic/49337-solved-line-break-in-php/#findComment-241849 Share on other sites More sharing options...
obsidian Posted April 30, 2007 Share Posted April 30, 2007 To answer the initial question, all you have to do to add a line break in text is add \r\n to the code. This will enter a carriage return into your plain text. What The Little Guy is doing is trying to show you how to format your MIME type to allow email messages. In addition, you need to check out the wordwrap() function. This can be one of the greatest assets to those sending text messages. Remember that about 80 characters should be the limit. Good luck! Link to comment https://forums.phpfreaks.com/topic/49337-solved-line-break-in-php/#findComment-241851 Share on other sites More sharing options...
The Little Guy Posted April 30, 2007 Share Posted April 30, 2007 Try this: <?php $query = "INSERT INTO messages (message,user_id,status,subject,from_p,received,to_email,time_sent) VALUES ('$message_x','$userid','1','$subject','$user_email','$DATE','$to','$TIME')"; $resultquery= mysql_query($query); $sentmsg_ID = mysql_insert_id(); //print ($sentmsg_ID); $sentquery = "INSERT INTO sent_messages (user_id, message_id) VALUES ('$userid', '$sentmsg_ID')"; $resultsent=mysql_query($sentquery); $id = mysql_insert_id(); $headers = "From: $name <$user_email>\n"; $headers .= "X-Sender: <$user_email>\n"; $headers .= "X-Mailer: PHP\n"; // mailer $headers .= "X-Priority: 1\n"; // Urgent message! $headers .= "Return-Path: <$varreturnpath>\n"; // Return path for errors $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $message = $name." has sent a message to you through InstiComm's message center. In order to get this message follow this link ".$varurlMC ." <p> PLEASE DO NOT REPLY TO THIS EMAIL AS THIS IS AN UNATTENDED, AUTO GENERATED EMAIL. </p>"; mail($to, "New Insticomm.com Mail From: ".$name, $message, $headers); header("Location: main.php?m1=".$_POST["m1"]."&d1=".$_POST["d1"]."&y1=".$_POST["y1"]."&m2=".$_POST["m2"]."&d2=".$_POST["d2"]."&y2=".$_POST["y2"]); exit; ?> Link to comment https://forums.phpfreaks.com/topic/49337-solved-line-break-in-php/#findComment-241864 Share on other sites More sharing options...
rsammy Posted April 30, 2007 Author Share Posted April 30, 2007 thanx obsidian. it worked. and thanx to little guy too! that code worked too! i'll use this one in future too! thanx guys. appreciate ur help Link to comment https://forums.phpfreaks.com/topic/49337-solved-line-break-in-php/#findComment-241877 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.