Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:55:51+00:00 2026-06-12T09:55:51+00:00

Code is below. I want it to separate the [From: xxxxxx] part so the

  • 0

Code is below. I want it to separate the [From: xxxxxx] part so the rest of the body/message appears on a different line.

<?php

    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = $_POST["message"];

    $recipient = "me@christianselig.com";
    $subject = "Message From Website";
    $body = "[From: " . $name . "]\n\n" . $message;
    $headers = "From: " . $email . "\r\n";
    $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";

    $success = mail($recipient, $subject, $body, $headers);

    echo $success;

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:55:52+00:00Added an answer on June 12, 2026 at 9:55 am

    You should use the HTML tag <br /> instead of \n

    Like this:

    $body = "[From: " . $name . "]<br /><br />" . $message;
    

    And a suggestion using the mail() function:

    if( mail($recipient, $subject, $body, $headers) )
        echo 'Success';
    else
        echo 'Fail';
    

    EDIT 1

    As you are trying to send as plain text you should use \r\n, this is the escape sequence for new line in plain text. Example:

    $formcontent="[From: " . $name . "]\r\n\r\n" . $message;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As a PHP developer, I always use the code below whenever I want to
See code below: I want Page 1 to alert #testing... This works in C
I have the code below and I want to loop this every 5 seconds.
The code below does not work but meant to illustrate what I want to
I want to know if the code below removes all input type='text' values back
Using the code below, I want to keep the same menu div opened in
In the code below, I don't want to use instanceof to know the type
I have the following code below which works, but I want to insert values
I have the code below with 3 columns. I want to have the border
I have this snippet of code below. I want to pass the value of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.