2014-09-23 50 views
1

我的代码有问题吗?PHP发送邮件功能在其他网页上不起作用

<?php 

$rand_2 = "abcdefghijklmnopqeABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 
$rand_key = substr(str_shuffle($rand_2), 0, 30); 


$to = "[email protected]"; 
$subject = "Account Validation"; 
$body = "Good Day! "."Mary Ann Linsey"."\n\n Copy this validation code below to 
confirm your registration in Portal \n\n".$rand_key; 
$header = "From: Portal"; 



if(mail($to, $subject, $body, $header)){ 
    echo 'Message has been sent to: <strong>'.$to.'</strong>'; 
}else{ 
    echo 'something went wrong'; 
} 

?> 

一些我发送电子邮件程序正在这块代码是不是我不为什么,我已经配置php.ini并send_mail.ini。

回答

0
<?php 

$rand_2 = "abcdefghijklmnopqeABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 
$rand_key = substr(str_shuffle($rand_2), 0, 30); 


$to = "[email protected]"; 
$subject = "Account Validation"; 
$body = "Good Day! "."Mary Ann Linsey"."\n\n Copy this validation code below to 
confirm your registration in Portal \n\n".$randn_key; 


$headers ="Reply-To: \"".$name."\" <".$email_sender.">\r\n"; 
$headers .="MIME-Version: 1.0\r\n"; 
$headers .="From: \"".$name."\" <".$email_sender.">\r\n"; 
$headers .="Content-Type: text/html; charset=utf-8\r\n"; 



if(mail($to, $subject, $body, $headers)){ 
    echo 'Message has been sent to: <strong>'.$to.'</strong>'; 
}else{ 
    echo 'something went wrong'; 
} 
?> 
+0

仍然无法正常工作 – 2014-09-23 05:35:27

+0

Windows对邮件系统的灵活性非常差,您现在正在面对的是这种邮件系统!尝试使用Linux机器测试您的代码。我检查了你的代码,它很好,把它上传到一个在线主机并测试它,它应该可以正常工作。 – freerunner 2014-09-23 05:47:21

+0

谢谢我已经找到答案我的标题包含太多字符 – 2014-09-23 07:29:54