在我的HTML中,我有一个表单提交部分。我使用mailto属性提交表单。它工作得很好,但我正在尝试的是,如果客户在表单中输入他们的电子邮件地址,然后提交表单,该电子邮件id将自动输入到邮箱的from地址,但我找不到解决方案。
<form action="mailto:sidhik64742@gmail.com" method="GET">
<div class="row pl-3">
<div class=" col-1">
<span class="fa mr-2 fa-user" aria-hidden="true"></span>
</div>
<div class="col-11 pr-5 ">
<input type="text" class="form-control w-75 form-background" name="fullname" id="fullName" placeholder="Full Name" required>
</div>
<br>
<br>
<div class="col-1">
<span class="fa fa-envelope-open" aria-hidden="true"></span>
</div>
<div class="col-11 pr-5">
<input type="email" class="form-control w-75 form-background" name="email" id="email" placeholder="Email" required>
</div>
<br>
<br>
<div class="col-1">
<span class="fa fa-phone" aria-hidden="true"></span>
</div>
<div class="col-11 pr-5">
<input type="mobile" class="form-control w-75 form-background" name="mobile" id="phone" placeholder="phone" required>
</div>
<br>
<br>
<div class="col-1">
<span class="fa mr-2 fa-edit" aria-hidden="true"></span>
</div>
<div class="col-11 pr-5">
<textarea class="form-control w-75 textarea form-background" rows="5" cols="40" name="comment" id="message" form="Myform" placeholder="Enter feedback here..." ></textarea>
</div>
<div class="col-12 p-3">
<input class="btn btn-primary button" id="" type="submit" value="Submit">
</div>
</div>
</form>
发布于 2020-05-19 01:10:04
如果你愿意,你可以用PHP来做这件事(如果你决定这样做,我建议把表单方法改成'POST‘):
<?php
if(isset($_POST['email'])){
$email = $_POST['email'];
$this = "";
// You would repeat the above for all the form attributes and place them below how you want
$body = "
This is where the body of the email will go. You can put variables in here like {$this}
";
$mail = mail("xxxx@gmail.com","The subject of the email",$body,"From: {$email}");
if($mail){
echo "Mail sent.";
} else {
echo "Mail not sent.";
}
}
?>希望这能有所帮助。
https://stackoverflow.com/questions/61874361
复制相似问题