试试这个,你的标题很时髦。对此进行了测试,结果有效。
<?php
ini_set('error_reporting', E_ALL);
error_reporting(E_ALL);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
if (isset($_POST['send'])) {
$name = $_POST['name'];
$from = "info@site.ir";
$to = 'kiarash@gmail.com';
$subject = 'Test Sending';
$message = 'You got a message from '. $name;
$headers = array(
'MIME-Version: 1.0',
'Content-Type: text/html; charset="UTF-8";',
'Content-Transfer-Encoding: 7bit',
'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
'From: ' . $from,
'Reply-To: ' . $from,
'Return-Path: ' . $from
);
$mailsent = mail($to, $subject, $message, implode("\n", $headers));
if($mailsent){
echo "success";
}else{
echo "not sent";
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="frm">
<input type="text" name="name" />
<input type="submit" value="send" name="send" />
</form>
</body>
</html>