我想发送一封电子邮件与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