<?php
$m = "";
$to = "anymail@gmail.com";
$from = "anymail@mydomainname.com";
$subject = 'subject';
$message = "Any Message";
$headers = "From: $from\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type:text/html; charset=iso-8859-1\n";
if ( mail($to, $subject, $message, $headers) ) {
$m = "Email sent successfully"; exit();
}else {
$m = "Email can't be sent.";exit();
}
exit();
?>
<!DOCTYPE HTML><html>
<head><meta charset="utf-8"><title>Untitled Document</title></head>
<body>
<h2>
<?php
echo $m;
?> </h2>
</body></html>
我无法得到确认。有谁可以指出这个问题?
答案 0 :(得分:0)
使用此代码,exit()
停止执行而不打印$m
if ( mail($to, $subject, $message, $headers) ) {
$m = "Email sent successfully";
//exit();
}else {
$m = "Email can't be sent.";
//exit();
}
//exit();