我想发送邮件的代码如下。我不明白他们正在发生。它适用于本地主机,但不适用于活动服务器。php邮件功能不能在线服务器上工作
if (isset($_POST['test_mail'])){
$to = '[email protected]'; //put email address on which mail send
$subject = "Newsletter"; //Put subject of mail here
$from = '[email protected]'; //put email address from
//email body start
// $body .= file_get_contents('file/'.$filename.'');
$body .= 'anio';
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: '.$from. "\r\n";
//if you need to send cc mail then uncomment below line and change email address
//$headers .= 'Cc: [email protected]' . "\r\n";
mail($to,$subject,$body,$headers);
}
您的邮件服务器没有配置或配置错误的php.ini。检查日志。 – 2014-12-13 08:13:03