在phpmailer头文件中的两个变量之间添加空格

I'm sending a form mail with php.

I need to set the "from:" to the form fields which live in the variables: $user_name and $user_lastname.

So i tried:

$headers .= 'From: ' . $user_name . " " . $user_lastname . "
";
$headers .= 'X-Mailer: PHP/' . phpversion();

But then i get "unknown sender" instead of name and last name.

try this:

$headers .= 'From: "'.$user_name." ".$user_lastname.'"<'.$user_email.'>'."
";

I believe you're simply using the wrong (").

Try this:

$headers .= 'From: '. $user_name .' '. $user_lastname;
$headers .= 'X-Mailer: PHP/' . phpversion();

Let me know if it isn't working