Thomas Ellison
Thomas Ellison

Reputation: 85

php \r\n output issue in email

i know this is probably a very simple issue and i've searched for answers on here and other places through google but still can't seem to get it to work. here's the issue. i have the following code:

$name = $_POST['Name'];
$phone = filter_var($_POST['Phone'], FILTER_SANITIZE_NUMBER_INT);
$address = $_POST['Address'];
$city = $_POST['City'];
$contact_time = $_POST['Call-Time'];
$job_descr = $_POST['Job-Description'];
$subject= $name. ' requested a quote';
$text = $name. " just requested a quote.\r\n";

foreach($_POST as $item => $key)// Get all of the variables sent and put them in a list
to be emailed
{   
    if(!empty($key) and $item != 'submit')
        $textappend .= "$item: $key\r\n";
}

$text .= "Information:\r\n$textappend";

the email collects all the variables and sends them. the only problem is that it does not output a new line where the \r\n is in the code. it just displays everything in a single line. am i not using the right quotation with the double quotes? any help would greatly be appreciated. thanks

Upvotes: 0

Views: 201

Answers (1)

Nicolás Torres
Nicolás Torres

Reputation: 1345

$headers .= "\n--$boundary\n"; // beginning \n added to separate previous content
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";

Pass the $headers variable to the mail function and let me know if it works

Upvotes: 1

Related Questions