Jump to content

[SOLVED] line break in php...


rsammy

Recommended Posts

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

<?
$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);
?>

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

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!

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;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.