简体   繁体   中英

I am trying to send email from a FORM using PHP, but i receive the details without the From email Address

I am trying to send email from a FORM, but i receive the details without the FROM email Address, help to rectify the issue.

/* HTML FORM CODE */

<form action="contact.php" method="post">
Name:<br><input type="text" name="name"><br>
From:<br><input type="text" name"from"><br>
Request:<br><textarea type="text" name="request"></textarea><br>
<input type="submit" name="submit" value="send">
</form>
/* HTML FORM CODE */

/* PHP SEND EMAIL CODE */
<?php
$name=$_POST['name'];
$from=$_POST['from'];
$request=$_POST['request'];

$to="skks1981@gmail.com";
$subject=$request;
$body=<<<EMAIL
Hai My name is $name

My email is $from

$request

EMAIL;
$header:$from;
mail($to,$subject,$body,$header);
echo "Message Sent";
?>

/* PHP SEND EMAIL CODE */

Note: In From part i receive unknown or admin@khatamband.com email address.

Thank in advance.

You should use this $header:

$header = "From: {$from}";

and not

$header:$from;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM