我用html创建了联系表格,并将其链接到php文件,以便在完成联系表格时向我发送电子邮件。由于某些原因,我没有收到电子邮件。
我不知道这些事情是否重要,但我希望它们提供上下文。
这是我的HTML代码
<form action="contact.php" target="_blank" method="post">
<div class="form-row mb-1">
<div class="col">
<input type="text" class="form-control form-control-
minimal" placeholder="Name" name="name">
</div>
<div class="col">
<input type="text" class="form-control form-control-
minimal" placeholder="Email" name="email">
</div>
<div class="col">
<input type="text" class="form-control form-control-
minimal" placeholder="Phone Number" name="phonenumber">
</div>
</div>
<div class="form-row mb-1">
<div class="col">
<textarea class="form-control form-control-minimal"
id="exampleFormControlTextarea1" rows="3" placeholder="Your Message"
name="message"></textarea>
</div>
</div>
<div class="form-row mt-2">
<div class="col">
<input type="checkbox" name="Facebook" value="Facebook"
name="facebook">
Facebook<br>
<input type="checkbox" name="Instagram"
value="Instagram" name="instagram">
Instagram<br>
<input type="checkbox" name="Search engine"
value="Search engine" name="searchengine">
Search engine<br>
<input type="checkbox" name="Referral" value="Referral"
name="referral">
Referral
</div>
</div>
<div class="form-row mt-3">
<div class="col">
<button type="submit" class="btn btn-primary px-
5">Submit
</button>
</div>
</div>
</form>
这是PHP
<?php
$emailto = 'timsmith@okcimage.com';
$toname = 'TO NAME';
$emailfrom = 'do_not_reply@okcimage.com';
$fromname = 'FROM NAME';
$subject = 'Email Subject';
$messagebody = 'Hello.';
$headers =
'Return-Path: ' . $emailfrom . "\r\n" .
'From: ' . $fromname . ' <' . $emailfrom . '>' . "\r\n" .
'X-Priority: 3' . "\r\n" .
'X-Mailer: PHP ' . phpversion() . "\r\n" .
'Reply-To: ' . $fromname . ' <' . $emailfrom . '>' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-Transfer-Encoding: 8bit' . "\r\n" .
'Content-Type: text/plain; charset=UTF-8' . "\r\n";
$params = '-f ' . $emailfrom;
$test = mail($emailto, $subject, $messagebody, $headers, $params);
?>
使用当前代码,PHP将运行,但是我不会收到电子邮件。请让我知道我需要更改的内容。