1and1上的php电子邮件表单

I am trying to combine the name field with the email field so that the email will be delivered like:

From: Name of Person Filling Out Form (email_address.com)

Goal: (Email From Line would contain the person's name and email).

I am using 1and1's mail.php function and there are no instructions on how to do this.

Is this even possible?

Here is my code:

<?php

echo '<link href="new/css/style.css" rel="stylesheet">';

// THE BELOW LINE STATES THAT IF THE SUBMIT BUTTON
// WAS PUSHED, EXECUTE THE PHP CODE BELOW TO SEND THE 
// MAIL. IF THE BUTTON WAS NOT PRESSED, SKIP TO THE CODE
// BELOW THE "else" STATEMENT (WHICH SHOWS THE FORM INSTEAD).
if ( isset ( $_POST [ 'buttonPressed' ] )){

// REPLACE THE LINE BELOW WITH YOUR E-MAIL ADDRESS.
$to = 'myemail.com' ;
$subject = 'From PHP contact page' ;

// NOT SUGGESTED TO CHANGE THESE VALUES
$message = $_POST [ "message" ] ;
$headers = 'From: ' . $_POST[ "from" ] . PHP_EOL ;
$name = $_POST['name'];
mail ( $to, $subject, $message, $headers ) ;

// THE TEXT IN QUOTES BELOW IS WHAT WILL BE 
// DISPLAYED TO USERS AFTER SUBMITTING THE FORM.

echo '<div id="msg_sent"> Your e-mail has been sent. You should receive a reply within a week. </div>';}

?>

Thank you if you know anything!

"I am using 1and1's mail.php function and there are no instructions on how to do this.
Is this even possible?"

Yes, it is possible.

Add an email form element <input type="text" name="email"> if you don't already have one, then do:

$email   = $_POST['email'];
$name    = $_POST['name'];
$headers = "From: ". $name . " <" . $email . ">
";

Mail stands at going to Spam if the From is only a name, instead of containg an Email address.

You should also use FILTER_VALIDATE_EMAIL for your email variable, in order to validate it.

I.e.:

if(!filter_var($email, FILTER_VALIDATE_EMAIL))
  {
  echo "E-mail is not valid.";
  }

Sidenote:
Rocket's comments make sense in regards to PHP_EOL which is why my example contains .