PHP联系表,不接收电子邮件[重复]

This question already has an answer here:

So, here we go with silly question number too many to count!

I've made a very simple PHP contact form using tutorials from the internet (I still need to add security measures to it but I wanted to get it working first) When I click on the send button on my website I do get the message sent script however no email arrives in my in box.

Any ideas what I'm doing wrong? The website is currently hosted locally via XAMPP.

$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$message = $_POST['message'];
$from = 'From: me@mywebsite.co.uk';
$to = 'me@mywebsite.co.uk';
$subject = 'Enquiry';

$body = "From: $name
 Company: $company
 Email: $email
 Telephone: $tel
 Message: $message
";

if ($_POST['send']) {
    if(mail($to, $subject, $body, $from)) {
        echo '<p> Your message has been sent!</p>';
    } else {
        echo '<p>Message could not be sent.<br>Please check that you have completed the name, email and message fields and try again</p>';
    }
}
</div>

As when I've previously set up contact forms I've been doing so using Code Igniter I didn't realise that I couldn't use mail() without installing a mail server.

Thanks to Parris Varney and RiggsFolly for pointing this out and thanks again to Riggs for letting me know that Code Igniter uses the PHPMailer library.

By using PHPmailer I was able to correct the code and get the form working perfectly in very short order.

For anyone interested the new code used with the latest version of PHPmailer is:

$name = $_REQUEST['name'];
$co = $_REQUEST['company'];
$email = $_REQUEST['email'];
$tel = $_REQUEST['tel'];
$message = $_REQUEST['message'];

require("PHPMailerAutoLoad.php");

$mail = new PHPMailer();

$mail->isSMTP();

$mail->Host = "mail.mydomain.co.uk";
$mail->SMTPAuth = true;
$mail->Username = "me@mydomain.co.uk";
$mail->Password = "password";
$mail->SMTPAutoTLS = false;

$mail->From = $email;
$mail->addAddress("me@mydomain.co.uk", "Me");
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Subject = "Enquiry";

$mail->Body = "From: $name<br>Company: $co<br>Email: $email<br>Telephone: $tel<br>Message: $message";
$mail->AltBody = "From: $name Company: $co Email: $email Telephone: $tel Message: $message";

if(!$mail->Send())
{
    echo "Message could not be sent";
}
echo "Message has been sent";
?>

Alright:

Step 1: check your error logs for any problems with the mail not being sent. Normally when installing an Apache inside windows the most people skip to set the from server and credentials.

I used WAMP alot and that one works normally only with an external account.

Step 2: If anything fails.

Download a mailer library and use Gmail to send the emails. Here is an tutorial on that : http://phpmailer.worxware.com/?pg=examplebgmail

Works great. Sure there is a lot of files in phpmailer but it works and easy to upgrade when new software versions are released.