3 回答
TA贡献1783条经验 获得超4个赞
试试这个
$email_to = "info@mail1.com,awhite@mail1.com";
$sitename = "Fraser";
$fullname = trim($_POST["fullname"]);
$email = trim($_POST["email"]);
$phone = trim($_POST["phone"]);
$message = "Name: $fullname \nContact Number: $phone \nEmail: $email";
$pagetitle = "Fraser Contact Form";
mail($email_to , $pagetitle, $message);
如果你的主机不阻止,它会工作,如果这样做!那么您将需要使用smtp,如gmail或其他提供商。
替代你可以使用 PHPMailer
TA贡献1943条经验 获得超7个赞
越来越多的托管商将使用mail()函数阻止发送发送给多个食谱的邮件,因为您可以提供任何由于SPF检查而被食谱阻止的“发件人”地址。您可以建立整个SMTP连接来发送邮件,也许可以使用像SwiftMailer这样的Lib。
TA贡献1862条经验 获得超6个赞
您如何发送要由php处理的数据。我已将脚本添加到表单操作中,并将您的提交按钮替换为提交类型的输入
断续器
<form id="contact-form" action="my_processing_script.php">
<div class="form-field-item">
<input type="text" required="required" name="fullname" id="fullname" size="25" placeholder="Name" class="form-field">
</div>
<div class="form-field-item">
<input type="tel" id="phone" name="phone" required="required" placeholder="Contact Number" class="form-field">
</div>
<div class="form-field-item">
<input type="email" required="required" name="email" id="email" placeholder="Email" class="form-field">
</div>
<div class="form-field-checkbox-item">
<div class="checkbox-item">
<input type="checkbox" id="agree-gdrp" name="agree-gdrp" required="required" value="Yes">
<label for="agree-gdrp" class="field-label">I agree that Fraser handles my personal data in accordance with GDPR</label>
</div>
</div>
<div class="form-submit-wrap">
<input type='submit' value='Send Enquiry'>
</div>
</form>
my_processing_script.php
<?php
$recepient = "info@mail1.com,awhite@mail1.com";
$sitename = "Fraser";
$fullname = trim($_POST["fullname"]);
$email = trim($_POST["email"]);
$phone = trim($_POST["phone"]);
$message = "Name: $fullname \nContact Number: $phone \nEmail: $email";
$pagetitle = "Fraser Contact Form";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: info@mail.com");
?>
如果您不想离开该页面,我建议您通过ajax或jquery post发布表格
<button id="my-submit-button">Send Enquiry</button>
JQuery
$("#my-submit-button").click(function(e){
var fullname = $("#fullname ").val()
var phone = $("#phone ").val()
var email = $("#email ").val()
var agree_gdrp = $("#agree-gdrp").val()
$.post("my_php_sctipt.php", {"fullname" :fullname, "phone":phone, "email" : email , "agree_gdrp": agree_gdrp }).done(function(evt){
alert("data sent");
})
})
- 3 回答
- 0 关注
- 143 浏览
添加回答
举报