Example 1. Sending mail.mail("[email protected]", "My Subject", "Line 1\nLine 2\nLine 3");
Example 2. Sending mail with extra headers.mail("[email protected]", "the subject", $message, "From: webmaster@$SERVER_NAME\r\n" ."Reply-To: webmaster@$SERVER_NAME\r\n" ."X-Mailer: PHP/" . phpversion());
Example 3. Sending mail with extra headers and setting an additional command line parameter.mail("[email protected]", "the subject", $message, "From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVER_NAME");
Example 4. Sending complex email./* recipients */ $to = "Mary <[email protected]>" . ", " ; //note the comma $to .= "Kelly <[email protected]>";/* subject */ $subject = "Birthday Reminders for August";/* message */ $message = ' <html> <head> <title>Birthday Reminders for August</title> </head> <body> <p>Here are the birthdays upcoming in August!</p> <table> <tr> <th>Person</th><th>Day</th><th>Month</th><th>Year</th> </tr> <tr> <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> </tr> <tr> <td>Sally</td><td>17th</td><td>August</td><td>1973</td> </tr> </table> </body> </html> ';/* To send HTML mail, you can set the Content-type header. */ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";/* additional headers */ $headers .= "From: Birthday Reminder <[email protected]>\r\n";$headers .= "Cc: [email protected]\r\n"; $headers .= "Bcc: [email protected]\r\n";/* and now mail it */ mail($to, $subject, $message, $headers);
Example 2. Sending mail with extra headers.mail("[email protected]", "the subject", $message,
"From: webmaster@$SERVER_NAME\r\n"
."Reply-To: webmaster@$SERVER_NAME\r\n"
."X-Mailer: PHP/" . phpversion());
Example 3. Sending mail with extra headers and setting an additional command line parameter.mail("[email protected]", "the subject", $message,
"From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVER_NAME");
Example 4. Sending complex email./* recipients */
$to = "Mary <[email protected]>" . ", " ; //note the comma
$to .= "Kelly <[email protected]>";/* subject */
$subject = "Birthday Reminders for August";/* message */
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";/* additional headers */
$headers .= "From: Birthday Reminder <[email protected]>\r\n";$headers .= "Cc: [email protected]\r\n";
$headers .= "Bcc: [email protected]\r\n";/* and now mail it */
mail($to, $subject, $message, $headers);
Example5:
<?
$message="abcdefghijklmnopqrstuvwxyz";
mail("[email protected]", "没有主题", $message, "From: [email protected]\nReply-To: [email protected]\nX-Mailer: PHP/" . phpversion());
?>
不過一定要在linux下才能用。win2k是不能用的。
smtp服务器的的话,比较多,我用的 imail,可以去网上下载的,它的功能比较多的,注意的是要在 php.ini中的mail function中设置
SMTP =localhost
sendmail_from=你自己的信箱。
还有mail()函数的参数不是很多吗?
格式 boolean mail(string to, string subject, string message, string [additional_headers]);
分别指 目标地址,主题,内容,以及 headers。
列子就不举,如果还有什么问题,欢迎来信。
我的计算机里没有smtp应该到哪去找呀!请您再说得详细点可以吗?
我将非常感谢。请您帮帮忙,我的确很着急!
请各位多帮帮忙。我一定高分回报!