联系表格不发送电子邮件

时间:2019-01-29 18:36:23

标签: php html

我有此代码,但它不会将电子邮件发送到我的电子邮件地址...我知道我必须更改该代码中的电子邮件。它只是随机发送一封电子邮件,不会被发送垃圾邮件。似乎php正在工作,因为我被重定向到退出通知...

这是我的HTML代码:

<form method=post action=sendmail.php>
   <div class=one_third>
      <label>Name</label>
      <input type=text name=author value id=name />
           </div>
<div class=one_third>
  <label>Email</label>
  <input type=text name=email value id=email />
</div>
<div class="one_third last">
  <label>Subject</label>
  <input type=text name=subject value id=subject />
</div>
<div class=full_width>
  <label>Your Message</label>
  <textarea name=msg id=msg></textarea>
</div>
<input type=submit name=submit value=Submit />

这是我的php代码:

<?php

/* Subject and email variables */

$emailsSubject = 'This is where you type what you subject will show up 
as';
$webMaster  = 'spam mail';


/* Gathering Data Variables - Whats in the form */

$name = $_POST ['name'];
$email = $_POST ['email'];
$subject = $_POST ['subject'];
$msg = $_POST['msg'];


/*Security*/




/* What You Want To See In The Email Place Inbetween $body = <<<EOD  and 
EOD; */    
$body = <<<EOD

<strong>Client:</strong> $name
<br />
<br />
<strong>Email:</strong> $email
<br />
<br />
<strong>Subject:</strong> $subject
<br />
<br />
______________________________________________
<br />
<br />
$msg

EOD;

/* Headers is a tag containing the users email and how you want it to 
display in your email */

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";

/* This is what sends the email */
$success = mail($webMaster, $emailsSubject, $body, $headers);

/* Results Rendered as Html */
echo file_get_contents("http://yourdomain.com/after-message-sent/");

?>

0 个答案:

没有答案