1

坚持一个简单的 php 邮件。任何人都可以发现我哪里出错了。很乐意提供任何帮助。

<?php
$to = "example@website.co.uk";
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
mail($name, $email, $subject, $message);
if(mail($name, $email, $subject, $message)) { 
  echo "E-Mail Sent"; 
} else { 
  echo "There was a problem"; 
}  
?>
4

2 回答 2

2

第一条评论几乎说明了一切,如果您需要该mail()函数的初学者友好教程,您应该查看PHP Sending E-mails

<?php
$to = "example@website.co.uk";
$name = 'From:'.$_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

if(mail($to, $subject, $message, $name)) { 
  echo "E-Mail Sent"; 
} else { 
  echo "There was a problem"; 
}  
?>
于 2013-07-15T19:10:23.747 回答
-2

试试这个,它需要防垃圾邮件等......

<?php
     $to      = 'example@example.com';
     $subject = $_POST['subject'];
     $message = $_POST['message'];
     $headers = 'From: contact@yoursite.com';

     mail($to, $subject, $message, $headers);
?>
于 2013-07-15T19:19:04.820 回答