我有这个脚本,我在自己的网站上使用:
<?php
error_reporting(E_ALL);
$email_subject = "New Customer Registration AP-Photography";
$from = "registrations@aftab-photography.dpwebdev.co.uk";
$email_to = "david@dpwebdev.co.uk";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message2 = "Hello! This is a automatic email message.";
$email_message2 .= "<BR>";
$email_message2 .= "<BR>";
$email_message2 .= "A New User has registered on aftab-photography.co.uk.";
$email_message2 .= "<BR>";
$email_message2 .= "<BR>";
$email_message2 .= '<td width="6%">Name:</td><td width="34%">'.clean_string($user_id).'</td>';
$email_message2 .= "<BR>";
$email_message2 .= "<BR>";
$email_message2 .= "Thanks";
$email_message2 .= "<BR>";
$email_message2 .= "Aftab-Photography";
$emailfrom = $from;
$emailto = "ap_photography@hotmail.co.uk";
// create email headers
$headers = 'From: '.$emailfrom."\r\n".
'Reply-To: '.$emailto."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message2, $headers);
echo "Mail Sent";
}
?>
这用于在客户在我的网站上注册时向我发送电子邮件,但它根本不向我发送电子邮件。
有什么想法吗?
大卫
BTW:我有一个默认安装的Linux服务器。
答案 0 :(得分:2)
检查mail()的返回值。如果是假,则发送邮件时出现问题。如果为true,则邮件发送正确,问题可能在邮件地址中。
检查你的php.ini,看看你的默认邮件程序是什么,以及它是如何配置的。
检查邮件日志以查看邮件是否正在排队/正确传送。
答案 1 :(得分:-1)
这个变量:
$from = "registrations@aftab-photography.dpwebdev.co.uk";
不能是这个必须是这样的:
$from = "registrations@aftab-photography.co.uk";