我想發送一封電子郵件與PHP。發送電子郵件在PHP - 空白電子郵件接收
我的問題其實是,發送的電子郵件是空白......
我的PHP函數:
function sendMail($template, $Email_Subject, $USR_Id, $USR_Email) {
$postdata = http_build_query(
array(
'subject' => $Email_Subject
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$message = file_get_contents('../../mail/'.$template.'.php', false, $context);
// Start configuring the email
$headers .= 'From: Company <[email protected]>' . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($USR_Email, $Email_Subject, $message, $headers);
}
我的template.php頁:
$message =
'<html>
...
<h1>Subject is : '.$_POST['subject'].'</h1>
...
<\html>';
echo $message;
我調用該函數像此:
sendMail("template", "Account Activation", $USR_Id, $USR_Email);
奇怪的是當我回應$message
,它不迴應我Subject is : ...
。它迴應我Subject is : '.$_POST['subject'].'
。就像如果PHP不工作...
任何人都可以幫我嗎?
謝謝。
你在的template.php回聲'$ message'?這似乎只是一個變量! – Kiyarash
是的。我也試着回報。 – teamo
用'echo'試一下...返回不適合這種情況... – Kiyarash