2
我已經使用curl
生成的報告和發送郵件給用戶。回聲json_encode響應不起作用的郵件功能
這裏是我的代碼
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, count($post));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
$ret = curl_exec($ch);
$ret = json_decode($ret, true);
curl_close($ch);
print_r($ret);
這裏我用我的郵件功能和返回JSON編碼迴應,但迴應沒有得到。 如果我評論send_report_to_user
功能,那麼我能夠得到響應
$to="[email protected]";
$name="Test";
$report_links='MYREPORT LINKS';
send_report_to_user($to,$name,$report_links);
echo json_encode(array('status'=>'success','message'=>"Report has been generated successfully. Please check your mail to view reports."));
die;
function send_report_to_user($to,$name,$report_links)
{
$mailheaders .= "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mailheaders .= "From: Mcs <[email protected]>";
$subject = "Your Report is Ready";
$body_message='<p>Your Report is now ready to be viewed here:</p>
<p><a href="'.$report_links.'" target="_blank">Click Here to view report</a></p>
<p> </p>';
mail($to,$subject,$body_message,$mailheaders);
return true;
}
你得到任何錯誤或異常試試? –
@RAUSHANKUMAR沒有代碼工作正常,只有響應沒有得到。也收到郵件 –
檢查你在這裏收到的郵件($ to,$ subject,$ body_message,$ mailheaders);' –