[英]PHP 'email sent' but not received
Stuck on a simple php mail thing. 卡在一个简单的php邮件上。 Can anybody spot where I've gone wrong. 谁能发现我错了。 Would be happy for any help. 希望得到任何帮助。
<?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";
}
?>
The first comment pretty much said it all, if you need a beginner-friendly tutorial of the mail()
function, you should check out PHP Sending E-mails 第一条注释几乎说明了一切,如果您需要对mail()
函数的初学者友好的教程,则应查看PHP发送电子邮件
<?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";
}
?>
Try this instead, it would need spam proofing etc... 请改用此方法,它需要防垃圾邮件等。
<?php
$to = 'example@example.com';
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: contact@yoursite.com';
mail($to, $subject, $message, $headers);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.