很簡單隻需要使用標頭mail()功能:
例如,您可以現在如果不使用此功能
<?php
function sendMail($to,$subject,$msg,$from = DEFULT_FROM){
// message
$message = '
<html>
<head>
</head>
<body dir="rtl">
<p align="right">'
. $msg .
'</p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=windows-1256' . "\n";
// Additional heade rs
$headers .= "From: ".$from . "\n";
//$headers .= 'Bcc: [email protected]' . "\n";
// Mail it
return mail($to, $subject, $message, $headers);
}
///// use
$message = " Hi World !";
$subject= "My subject ";
[email protected] /// change $username with your variable
$to ="[email protected]" ;
/////// call function
$check = sendMail($to,$subject,$message ,$from);
if($check){
echo " Sent :) ";
}
else{
echo " Not Sent :(";
}
?>
你是如何設置發件人姓名與頭? – JJJ
您是否使用php的郵件功能http://www.php.net/manual/en/function.mail.php或PHPMailer http://phpmailer.worxware.com/index.php?pg=exbsbsmtp? –